code: def expand_dims(t, axis):
      """Add a new dimension to tensor `t` along `axis`.
  
      Args:
        t: A `tf.Tensor` or `tf.SparseTensor`.
        axis: A `0D` integer scalar.
  
      Returns:
        An expanded tensor.
  
      Raises:
        NotImplementedError: If `t` is a `SparseTensor` and `axis != 0`.
      """
      if isinstance(t, tf.SparseTensor):
          if tf.is_tensor(axis) or axis != 0:
              raise NotImplementedError(
                  "Can only expand_dims on SparseTensor {} on static axis 0, "
                  "but received axis {}".format(t, axis)
              )
          n_elem = (
              t.indices.shape[0]
              or tf.get_static_shape(t.dense_shape)[0]
              or tf.shape(t.indices)[0]
          )
          shape_ = tf.cast(t.shape, tf.int64)
          return tf.SparseTensor(
              indices=tf.concat(
                  (tf.zeros([n_elem, 1], dtype=tf.int64), t.indices),
                  axis=1,
              ),
              values=t.values,
              dense_shape=tf.concat(([1], shape_), axis=0),
          )
      else:
          return tf.expand_dims(t, axis)
  
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 4 for calling a global function with example usage: expand_dims(t, axis) and returns: tf, tf