code: def testCompositeTensorSerialization(self):
      encodable_jd = jdn.JointDistributionNamed(  # No lambdas.
          dict(
              e=independent.Independent(
                  exponential.Exponential(rate=[10, 12]), 1
              ),
              loc=normal.Normal(loc=0, scale=2.0),
              m=normal.Normal(loc=-1.0, scale=1.0),
          ),
          validate_args=True,
      )
  
      enc = tf.__internal__.saved_model.encode_structure(
          encodable_jd._type_spec
      )
      dec = tf.__internal__.saved_model.decode_proto(enc)
      flat = tf.nest.flatten(encodable_jd, expand_composites=True)
      deserialized_flat = dec._to_components(encodable_jd)
      unflat = tf.nest.pack_sequence_as(
          encodable_jd, flat, expand_composites=True
      )
      deserialized_unflat = dec._from_components(deserialized_flat)
  
      self.assertEqual(dec, encodable_jd._type_spec)
      self.assertAllEqualNested(
          flat,
          tf.nest.flatten(deserialized_flat, expand_composites=True),
      )
      self.assertIsInstance(
          deserialized_unflat, jdn.JointDistributionNamed
      )
      self.assertIs(type(unflat.model), type(deserialized_unflat.model))
  
      non_ct_jd = jdn.JointDistributionNamed(
          dict(
              e=normal.Normal(loc=0, scale=2.0),
              m=transformed_distribution.TransformedDistribution(
                  normal.Normal(loc=-1.0, scale=1.0),
                  bijector_test_util.NonCompositeTensorExp(),
              ),
          )
      )
      self.assertNotIsInstance(
          non_ct_jd, tf.__internal__.CompositeTensor
      )
  
imports: import collections
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector_test_util
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import beta
  from tensorflow_probability.python.distributions import exponential
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.distributions import half_normal
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import joint_distribution_named
  from tensorflow_probability.python.distributions import joint_distribution_sequential
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import sample
  from tensorflow_probability.python.distributions import student_t
  from tensorflow_probability.python.distributions import transformed_distribution
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 24 for calling the JointDistributionNamedTest obj's underlying member method code with example usage: obj.testCompositeTensorSerialization() without return types