class_docstr: Strategy extension that support both single and multi worker strategy.
code: def _experimental_distribute_values_from_function(self, value_fn):
      per_replica_values = []
      # Note that in the multi-worker setting, this function only return the
      # slide of DistributedValue for the current worker.
      for i in range(self._mesh.num_local_devices()):
          # In the case of 2 worker with 2 local devices on each worker,
          # worker 0 will get 0 and 1 for replica_id.
          # worker 1 will get 2 and 3 for replica_id.
          replica_id = (
              d_config.client_id() * self._mesh.num_local_devices() + i
          )
          per_replica_values.append(
              value_fn(
                  distribute_lib.ValueContext(
                      replica_id, self._num_replicas_in_sync
                  )
              )
          )
      # Instead of using the DistributeVariable, return a DTensor instead since
      # the run() will expect a DTensor instance.
      result = distribute_utils.regroup(
          per_replica_values, always_wrap=True
      )
      map_fn = functools.partial(
          dtensor_util.convert_per_replica_to_dtensor, mesh=self._mesh
      )
      return nest.map_structure(map_fn, result)
  
imports: import functools
  from tensorflow.dtensor.python import api
  from tensorflow.dtensor.python import config
  from tensorflow.dtensor.python import d_variable
  from tensorflow.dtensor.python import input_util
  from tensorflow.dtensor.python import layout
  from tensorflow.python.data.experimental.ops import distribute
  from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.distribute import distribute_utils
  from tensorflow.python.distribute.experimental import dtensor_util
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 14 for calling the DTensorStrategyExtended obj's underlying member method code with example usage: obj._experimental_distribute_values_from_function(value_fn) and returns: nest