def _as_indexed_slices(x, optimize=True):
    "Convert 'x' to IndexedSlices.\n\n  Convert a dense Tensor to a block-sparse IndexedSlices.\n\n  Args:\n    x: Either a Tensor object, or an IndexedSlices object.\n    optimize: if true, attempt to optimize the conversion of 'x'.\n\n  Returns:\n    An IndexedSlices object.\n\n  Raises:\n    TypeError: If 'x' is not a Tensor or an IndexedSlices object.\n  "
    if (not isinstance(x, (ops.Tensor, ops.IndexedSlices))):
        raise TypeError(('Not a Tensor or IndexedSlices: %s' % type(x)))
    if isinstance(x, ops.IndexedSlices):
        return x
    x_shape = array_ops.shape_internal(x, optimize=optimize)
    return ops.IndexedSlices(x, range(0, x_shape[0]), x_shape)
Convert 'x' to IndexedSlices.

Convert a dense Tensor to a block-sparse IndexedSlices.

Args:
  x: Either a Tensor object, or an IndexedSlices object.
  optimize: if true, attempt to optimize the conversion of 'x'.

Returns:
  An IndexedSlices object.

Raises:
  TypeError: If 'x' is not a Tensor or an IndexedSlices object.
def _as_indexed_slices(x, optimize=True):
    "Convert 'x' to IndexedSlices.\n\n  Convert a dense Tensor to a block-sparse IndexedSlices.\n\n  Args:\n    x: Either a Tensor object, or an IndexedSlices object.\n    optimize: if true, attempt to optimize the conversion of 'x'.\n\n  Returns:\n    An IndexedSlices object.\n\n  Raises:\n    TypeError: If 'x' is not a Tensor or an IndexedSlices object.\n  "
    if (not isinstance(x, (ops.Tensor, ops.IndexedSlices))):
        raise TypeError(('Not a Tensor or IndexedSlices: %s' % type(x)))
    if isinstance(x, ops.IndexedSlices):
        return x
    x_shape = array_ops.shape_internal(x, optimize=optimize)
    return ops.IndexedSlices(x, range(0, x_shape[0]), x_shape)