code: def _to_numpy(a):
      """Converts Tensors, EagerTensors, and IndexedSlicesValue to numpy arrays.
  
      Args:
        a: any value.
  
      Returns:
        If a is EagerTensor or Tensor, returns the evaluation of a by calling
        numpy() or run(). If a is IndexedSlicesValue, constructs the corresponding
        dense numpy array. Otherwise returns a unchanged.
      """
      if isinstance(a, ops.EagerTensor):
          return a.numpy()
      if isinstance(a, tensor.Tensor):
          sess = ops.get_default_session()
          return sess.run(a)
      if isinstance(a, indexed_slices.IndexedSlicesValue):
          arr = np.zeros(a.dense_shape)
          assert len(a.values) == len(a.indices), (
              "IndexedSlicesValue has %s value slices but %s indices\n%s"
              % (a.values, a.indices, a)
          )
          for values_slice, index in zip(a.values, a.indices):
              assert (
                  0 <= index < len(arr)
              ), "IndexedSlicesValue has invalid index %s\n%s" % (
                  index,
                  a,
              )
              arr[index] += values_slice
          return arr
      return a
  
imports: import numpy
  from tensorflow.python.eager import backprop
  from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 3 for calling a global function with example usage: _to_numpy(a) and returns: a, a, sess, arr