def copy_tensor_or_indexed_slices_to_device(value, device):
    with ops.device(device):
        if isinstance(value, ops.IndexedSlices):
            copied_values = array_ops.identity(value.values)
            copied_indices = array_ops.identity(value.indices)
            copied_shape = array_ops.identity(value.dense_shape)
            result = ops.IndexedSlices(copied_values, copied_indices, copied_shape)
        else:
            result = array_ops.identity(value)
    return result
def copy_tensor_or_indexed_slices_to_device(value, device):
    with ops.device(device):
        if isinstance(value, ops.IndexedSlices):
            copied_values = array_ops.identity(value.values)
            copied_indices = array_ops.identity(value.indices)
            copied_shape = array_ops.identity(value.dense_shape)
            result = ops.IndexedSlices(copied_values, copied_indices, copied_shape)
        else:
            result = array_ops.identity(value)
    return result