code: def _make_allreduce_grads_fn(name, device):
      def allreduce_grads(grads):
          with tf.name_scope(name + "_Allreduce"):
              ar_grads = [
                  allreduce(grad, device=device)
                  if grad is not None
                  else grad
                  for grad in grads
              ]
          return ar_grads
  
      if _executing_eagerly():
          if hasattr(tf, "function"):
              # TensorFlow 1.14.0+
              return tf.function(allreduce_grads)
          else:
              return tf.contrib.eager.defun(allreduce_grads)
      else:
          return allreduce_grads
  
imports: import tensorflow
  from bluefog.tensorflow.mpi_ops import allreduce, broadcast, size
  from bluefog.tensorflow.util import _executing_eagerly, _cache
label_desc: Use image node_id 1 for calling a global function with example usage: _make_allreduce_grads_fn(name, device) and returns: ar_grads, allreduce_grads, tf, tf