code: def AggregateIndexedSlicesGradients(grads):
      """Aggregates gradients containing `IndexedSlices`s."""
      if len(grads) < 1:
          return None
      if len(grads) == 1:
          return grads[0]
      grads = [g for g in grads if g is not None]
      # If any gradient is a `Tensor`, sum them up and return a dense tensor
      # object.
      if any(isinstance(g, tensor_lib.Tensor) for g in grads):
          return math_ops.add_n(grads)
  
      # The following `_as_indexed_slices_list` casts ids of IndexedSlices into
      # int64. It is to make sure the inputs of `concat` all have same the data
      # type.
      grads = math_ops._as_indexed_slices_list(
          grads
      )  # pylint: disable=protected-access
  
      grads = [FlattenNestedIndexedSlices(x) for x in grads]
      # Form IndexedSlices out of the concatenated values and indices.
      concat_grad = indexed_slices.IndexedSlices(
          array_ops.concat([x.values for x in grads], axis=0),
          array_ops.concat([x.indices for x in grads], axis=0),
          grads[0].dense_shape,
      )
  
      return concat_grad
  
file_path: tensorflow/tensorflow/python/eager/backprop_util.py
imports: from tensorflow.core.config import flags
  from tensorflow.core.framework import types_pb2
  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.framework import tensor_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import handle_data_util
  from tensorflow.python.ops import math_ops
label_desc: Use image node_id 4 for calling a global function with example usage: AggregateIndexedSlicesGradients(grads) and returns: concat_grad, None, grads, math_ops