code: def gather(strategy, value):
      """Gathers value from all workers.
  
      This is intended for tests before we implement an official all-gather API.
  
      Args:
        strategy: a `tf.distribute.Strategy`.
        value: a nested structure of n-dim `tf.distribute.DistributedValue` of
          `tf.Tensor`, or of a `tf.Tensor` if the strategy only has one replica.
          Cannot contain tf.sparse.SparseTensor.
  
      Returns:
        a (n+1)-dim `tf.Tensor`.
      """
      return nest.map_structure(
          functools.partial(_gather, strategy), value
      )
  
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 2 for calling a global function with example usage: gather(strategy, value) and returns: nest