class_docstr: LocalGradientAggregationHelper aggregates gradient updates locally,
  and communicates the updates across machines only once every
  backward_passes_per_step. Only supports graph mode execution.
class_docstr_tok: ["LocalGradientAggregationHelper","aggregates","gradient","updates","locally",",","and","communicates","the","updates","across","machines","only","once","every","backward_passes_per_step",".","Only","supports","graph","mode","execution","."]
code: def _maybe_convert_grad(self, grad):
      # Handle IndexedSlices.
      if isinstance(grad, tf.IndexedSlices):
          if self.sparse_as_dense:
              return tf.convert_to_tensor(grad)
          else:
              raise ValueError(
                  "IndexedSlices are not supported when "
                  "`backward_passes_per_step` > 1 and "
                  "`sparse_as_dense` is False."
              )
  
      return grad
  
file_path: horovod/horovod/tensorflow/gradient_aggregation.py
imports: import os
  import tensorflow
  from packaging import version
  from horovod.tensorflow.mpi_ops import size_op
  from horovod.tensorflow.mpi_ops import global_process_set
label_desc: Use image node_id 3 for calling the LocalGradientAggregationHelper obj's underlying member method code with example usage: obj._maybe_convert_grad(grad) and returns: grad, tf