code: def make_per_replica_value(value, devices):
      """Creates a `PerReplica` object whose values reside in `devices`.
  
      Args:
        value: a tensor-convertible value or a `IndexedSlicesValue`, or a callable
          that takes one argument (`device_idx`) and should return the value that is
          going to be created on devices[device_idx].
        devices: a list of device strings to create `PerReplica` values on.
  
      Returns:
        A `PerReplica` object.
      """
      values = []
      for device_idx, device in enumerate(devices):
          if callable(value):
              v = value(device_idx)
          elif isinstance(value, list):
              v = value[device_idx]
          else:
              v = value
          if isinstance(v, IndexedSlicesValue):
              with ops.device(device):
                  values.append(
                      IndexedSlices(
                          values=array_ops.identity(v.values),
                          indices=array_ops.identity(v.indices),
                          dense_shape=array_ops.identity(v.dense_shape),
                      )
                  )
          else:
              with ops.device(device):
                  values.append(array_ops.identity(v))
      return value_lib.PerReplica(values)
  
imports: import collections
  import os
  import threading
  import time
  from absl.testing import parameterized
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.core.protobuf import tensorflow_server_pb2
  from tensorflow.python.distribute import cluster_resolver
  from tensorflow.python.distribute import collective_util
  from tensorflow.python.distribute import combinations
  from tensorflow.python.distribute import cross_device_ops
  from tensorflow.python.distribute import cross_device_utils
  from tensorflow.python.distribute import device_util
  from tensorflow.python.distribute import multi_process_runner
  from tensorflow.python.distribute import multi_worker_test_base
  from tensorflow.python.distribute import reduce_util
  from tensorflow.python.distribute import test_util
  from tensorflow.python.distribute import values
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import test
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import collective_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import math_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 for calling a global function with example usage: make_per_replica_value(value, devices) and returns: value_lib