class_docstr: LocalGradientAggregationHelperEager aggregates gradient updates
  locally, and communicates the updates across machines only once
  every backward_passes_per_step. Only supports eager execution.
code: def _allreduce_helper(self, grads, vars):
      def __filtered_reduce_grads(grads, vars):
          rv = []
          rg = []
          if _IS_TF2:
              v2g = {var.ref(): grad for var, grad in zip(vars, grads)}
              for var, grad in zip(vars, grads):
                  if var.ref() not in self._local_vars:
                      rv.append(var)
                      rg.append(grad)
          else:
              v2g = {var: grad for var, grad in zip(vars, grads)}
              for var, grad in zip(vars, grads):
                  if var not in self._local_vars:
                      rv.append(var)
                      rg.append(grad)
  
          rg = self.allreduce_grads(rg, rv)
          horovod_size = (
              size_op(process_set_id=self.process_set.process_set_id)
              if int(os.environ.get("HOROVOD_ELASTIC", 0))
              else self.process_set.size()
          )
          if _IS_TF2:
              for rv, rg in zip(rv, rg):
                  v2g[rv.ref()] = rg
  
              if self.scale_local_gradients and len(self._local_vars):
                  # Scale local gradients by a size factor. See pull/3695 and discussions/3705 for context.
                  for v_ref in v2g:
                      if (
                          v_ref in self._local_vars
                          and v2g[v_ref] is not None
                      ):
                          v2g[v_ref] /= float(horovod_size)
  
              return [v2g[rv.ref()] for rv in vars]
          else:
              for rv, rg in zip(rv, rg):
                  v2g[rv] = rg
  
              if self.scale_local_gradients and len(self._local_vars):
                  # Scale local gradients by a size factor. See pull/3695 and discussions/3705 for context.
                  for v in v2g:
                      if v in self._local_vars and v2g[v] is not None:
                          v2g[v] /= float(horovod_size)
  
              return [v2g[rv] for rv in vars]
  
      allreduced_grads = __filtered_reduce_grads(grads, vars)
  
      if not self.average_aggregated_gradients:
          return allreduced_grads
  
      scaled_allreduced_grads = []
      for grad in allreduced_grads:
          if grad is None:
              scaled_allreduced_grads.append(grad)
              continue
  
          scaled_allreduced_grads.append(
              grad / self.backward_passes_per_step
          )
  
      return scaled_allreduced_grads
  
file_path: horovod/horovod/tensorflow/gradient_aggregation_eager.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 4 for calling the LocalGradientAggregationHelperEager obj's underlying member method code with example usage: obj._allreduce_helper(grads, vars) and returns: scaled_allreduced_grads, allreduced_grads, unknown, unknown