code: def reduce_non_distributed_value(
      reduce_op, device_map, value, destinations
  ):
      """Reduce a non-DistributedValue `value` to `destinations`."""
      if isinstance(value, value_lib.DistributedValues):
          raise ValueError(
              "You are passing a `DistributedValue` to "
              "`reduce_non_distributed_value`, which is not allowed."
          )
  
      # If the same value is present on all replicas then the PerReplica value will
      # be a single value. We also handle the case when `value` is a single value
      # and equal to 0.
      # TODO:(b/138823479): handle the tensor value properly.
      if not tensor_util.is_tensor(value) and value == 0:
          return 0
      # If there is only a single value and the reduce op is MEAN,
      # that value should be on all destinations.
      if reduce_op == reduce_util.ReduceOp.MEAN:
          return value
  
      validate_destinations(destinations)
      # We do not support a reduce op of SUM if the value is the same across
      # all replicas. We call this as part of assign functions for MirroredVariables
      # and summing up identical values across replicas is not clearly defined.
      if device_map.num_replicas_in_graph != 1:
          raise ValueError(
              "A non-DistributedValues value %s cannot be reduced with "
              "the given reduce op %s." % (value, reduce_op)
          )
      return simple_broadcast(value, destinations)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import enum
  import six
  from tensorflow.python.client import device_lib
  from tensorflow.python.distribute import cross_device_utils
  from tensorflow.python.distribute import device_util
  from tensorflow.python.distribute import reduce_util
  from tensorflow.python.distribute import values
  from tensorflow.python.eager import context
  from tensorflow.python.framework import kernels
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util.tf_export import tf_export
  from tensorflow.tools.docs import doc_controls
  import tensorflow
  from tensorflow.python.distribute.cross_device_ops import CollectiveAllReduce
  import tensorflow.python.distribute.cross_device_ops
  from byteps.tensorflow.ops import broadcast, _push_pull
  from byteps.tensorflow import local_rank, size
label_desc: Use image node_id 3 for calling a global function with example usage: reduce_non_distributed_value(reduce_op, device_map, value, destinations) and returns: simple_broadcast, int, value