class_docstr: Sets up distributed devices and sharding.
code: def per_replica_to_composite_tensor(self, value):
      if JAX_MODE:
          return value
      flattened = tf.nest.flatten(value, expand_composites=True)
      stride = len(flattened) // NUM_DEVICES
      reshaped = [flattened[idx::stride] for idx in range(stride)]
  
      return tf.nest.pack_sequence_as(
          value.values[0], reshaped, expand_composites=True
      )
  
file_path: probability/tensorflow_probability/python/internal/distribute_test_lib.py
imports: import os
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 3 for calling the DistributedTest obj's underlying member method code with example usage: obj.per_replica_to_composite_tensor(value) and returns: tf, value