code: def test_dict_sample_log_prob(self):
      # pylint: disable=bad-whitespace
      d = jdn.JointDistributionNamed(
          dict(
              e=independent.Independent(
                  exponential.Exponential(rate=[100, 120]), 1
              ),
              scale=lambda e: gamma.Gamma(  # pylint: disable=g-long-lambda
                  concentration=e[..., 0], rate=e[..., 1]
              ),
              loc=normal.Normal(loc=0, scale=2.0),
              m=normal.Normal,
              x=lambda m: sample_lib.Sample(
                  bernoulli.Bernoulli(logits=m), 12
              ),
          ),
          validate_args=True,
      )
      # pylint: enable=bad-whitespace
  
      keys = ("e", "scale", "loc", "m", "x")
      deps = ((), ("e",), (), ("loc", "scale"), ("m",))
      self.assertEqual(tuple(zip(keys, deps)), d.resolve_graph())
  
      xs = d.sample(seed=test_util.test_seed())
      self.assertLen(xs, 5)
      # We'll verify the shapes work as intended when we plumb these back into the
      # respective log_probs.
  
      ds, _ = d.sample_distributions(
          value=xs, seed=test_util.test_seed()
      )
      self.assertLen(ds, 5)
      self.assertIsInstance(ds["e"], independent.Independent)
      self.assertIsInstance(ds["scale"], gamma.Gamma)
      self.assertIsInstance(ds["loc"], normal.Normal)
      self.assertIsInstance(ds["m"], normal.Normal)
      self.assertIsInstance(ds["x"], sample_lib.Sample)
  
      # Static properties.
      self.assertAllEqual(
          {
              "e": tf.float32,
              "scale": tf.float32,
              "loc": tf.float32,
              "m": tf.float32,
              "x": tf.int32,
          },
          d.dtype,
      )
  
      batch_shape_tensor_, event_shape_tensor_ = self.evaluate(
          [d.batch_shape_tensor(), d.event_shape_tensor()]
      )
  
      expected_batch_shape = {
          "e": [],
          "scale": [],
          "loc": [],
          "m": [],
          "x": [],
      }
      batch_tensorshape = d.batch_shape
      for k in expected_batch_shape:
          self.assertAllEqual(
              expected_batch_shape[k], batch_tensorshape[k]
          )
          self.assertAllEqual(
              expected_batch_shape[k], batch_shape_tensor_[k]
          )
  
      expected_event_shape = {
          "e": [2],
          "scale": [],
          "loc": [],
          "m": [],
          "x": [12],
      }
      event_tensorshape = d.event_shape
      for k in expected_event_shape:
          self.assertAllEqual(
              expected_event_shape[k], event_tensorshape[k]
          )
          self.assertAllEqual(
              expected_event_shape[k], event_shape_tensor_[k]
          )
  
      expected_lp_parts = {k: ds[k].log_prob(xs[k]) for k in ds.keys()}
      expected_jlp = sum(expected_lp_parts.values())
      actual_jlp = d.log_prob(xs)
      self.assertAllClose(expected_jlp, actual_jlp, atol=0.0, rtol=1e-4)
      self.assertAllCloseNested(
          expected_lp_parts, d.log_prob_parts(xs), atol=0.0, rtol=1e-4
      )
      self.assertAllCloseNested(
          expected_lp_parts, d.log_prob_parts(**xs), atol=0.0, rtol=1e-4
      )
  
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 1 for calling the JointDistributionNamedTest obj's underlying member method code with example usage: obj.test_dict_sample_log_prob() without return types