class_docstr: Tests the correctness of the Y = Restructure({nested}) transformation.
class_docstr_tok: ["Tests","the","correctness","of","the","Y","=","Restructure","(","{","nested","}",")","transformation","."]
code: def testPartsWithUnusedInternalStructure(self):
      dist = joint_distribution_sequential.JointDistributionSequential(
          [
              joint_distribution_named.JointDistributionNamed(
                  {"a": normal.Normal(0.0, 1.0)}
              ),
              joint_distribution_named.JointDistributionNamed(
                  {"b": normal.Normal(1000.0, 1.0)}
              ),
          ]
      )
      x = dist.sample(  # Shape: [{'a': []}, {'b': []}]
          seed=test_util.test_seed(sampler_type="stateless")
      )
  
      # Test that we can swap the outer list entries, even though they contain
      # internal structure (i.e., are themselves dicts).
      swap_elements = restructure.Restructure(
          input_structure=[1, 0], output_structure=[0, 1]
      )
      self.assertAllEqualNested(
          swap_elements(x), [x[1], x[0]], check_types=True
      )
  
      swapped_dist = swap_elements(dist)
      self.assertAllEqualNested(
          swapped_dist.event_shape,
          [dist.event_shape[1], dist.event_shape[0]],
          check_types=True,
      )
      self.assertEqual(
          swapped_dist.dtype, [dist.dtype[1], dist.dtype[0]]
      )
  
file_path: probability/tensorflow_probability/python/bijectors/restructure_test.py
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import restructure
  from tensorflow_probability.python.distributions import joint_distribution_named
  from tensorflow_probability.python.distributions import joint_distribution_sequential
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 6 for calling the RestructureBijectorTest obj's underlying member method code with example usage: obj.testPartsWithUnusedInternalStructure() without return types