code: def _gather(strategy, value):
      """Gathers a single value."""
      # pylint: disable=protected-access
      if not isinstance(value, values.DistributedValues):
          value = values.PerReplica([ops.convert_to_tensor(value)])
      if not isinstance(
          strategy.extended,
          collective_all_reduce_strategy.CollectiveAllReduceExtended,
      ):
          return array_ops_stack.stack(value._values)
      assert len(strategy.extended.worker_devices) == len(value._values)
      inputs = [
          array_ops.expand_dims_v2(v, axis=0) for v in value._values
      ]
      return strategy.gather(values.PerReplica(inputs), axis=0)
  
imports: import collections
  import dataclasses
  import functools
  import io
  import itertools
  import threading
  from absl import app
  from tensorflow.python.compat import v2_compat
  from tensorflow.python.distribute import collective_all_reduce_strategy
  from tensorflow.python.distribute import multi_process_runner
  from tensorflow.python.distribute import multi_worker_test_base
  from tensorflow.python.distribute import tpu_strategy
  from tensorflow.python.distribute import values
  from tensorflow.python.eager import context
  from tensorflow.python.framework import config
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.util import nest
label_desc: Use image node_id 3 for calling a global function with example usage: _gather(strategy, value) and returns: strategy, array_ops_stack