code: def slice_from(tensor, axis, start):
      """Slice a composite tensor along `axis` from `start`.
  
      Examples:
  
      ```python
      slice_from(tensor, 2, 1) === tensor[:, :, 1:]
      sparse_to_dense(slice_from(sparse_tensor, 2, 1))
        === sparse_to_dense(sparse_tensor)[:, :, 1:]
      ```
  
      Args:
        tensor: A `Tensor` or `SparseTensor`.
        axis: A python integer.
        start: A `0D` scalar.
  
      Returns:
        The sliced composite tensor.
      """
      if isinstance(tensor, tf.SparseTensor):
          if not tf.is_tensor(start) and start < 0:
              start = tensor.dense_shape[axis] + start
          all_but_first = tf.reshape(
              tf.where(tensor.indices[:, axis] >= start), [-1]
          )
          indices = tf.gather(tensor.indices, all_but_first)
          indices = tf.unstack(indices, axis=1)
          indices = tf.stack(
              indices[:axis]
              + [indices[axis] - start]
              + indices[axis + 1 :],
              axis=1,
          )
          new_shape = tf.unstack(tensor.dense_shape)
          new_shape[axis] = new_shape[axis] - start
          return tf.SparseTensor(
              indices=indices,
              values=tf.gather(tensor.values, all_but_first),
              dense_shape=tf.stack(new_shape),
          )
      else:
          ndims = len(tensor.shape)
          if ndims is None:
              raise ValueError(
                  "Unable to slice a tensor with unknown rank: {}".format(
                      tensor
                  )
              )
          slices = tuple(
              [slice(None)] * axis
              + [slice(start, None)]
              + [slice(None)] * (ndims - axis - 1)
          )
          return tensor[slices]
  
file_path: agents/tf_agents/utils/composite.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
label_desc: Use image node_id 5 for calling a global function with example usage: slice_from(tensor, axis, start) and returns: tf, tensor