code: def test_sample_and_log_prob(self, jd_class):
      # Define a bijector to detect if/when `inverse` is called.
      inverted_values = []
  
      class InverseTracingExp(exp.Exp):
          def _inverse(self, y):
              inverted_values.append(y)
              return tf.math.log(y)
  
      models = {}
  
      def coroutine_model():
          g = yield InverseTracingExp()(
              normal.Normal(0.0, 1.0), name="g"
          )
          df = yield exponential.Exponential(1.0, name="df")
          loc = yield sample_lib.Sample(
              normal.Normal(0, g), 20, name="loc"
          )
          yield student_t.StudentT(df, loc, 1, name="x")
  
      models[
          jdab.JointDistributionCoroutineAutoBatched
      ] = coroutine_model
  
      models[jdab.JointDistributionSequentialAutoBatched] = [
          InverseTracingExp()(normal.Normal(0.0, 1.0), name="g"),
          exponential.Exponential(1.0, name="df"),
          lambda _, g: sample_lib.Sample(
              normal.Normal(0, g), 20, name="loc"
          ),
          lambda loc, df: student_t.StudentT(df, loc, 1, name="x"),
      ]
  
      models[
          jdab.JointDistributionNamedAutoBatched
      ] = collections.OrderedDict(
          (
              ("g", InverseTracingExp()(normal.Normal(0.0, 1.0))),
              ("df", exponential.Exponential(1.0)),
              (
                  "loc",
                  lambda g: sample_lib.Sample(normal.Normal(0, g), 20),
              ),
              ("x", lambda loc, df: student_t.StudentT(df, loc, 1)),
          )
      )
  
      joint = jd_class(models[jd_class], validate_args=True)
  
      seed = test_util.test_seed(sampler_type="stateless")
      for sample_shape in ([], [5]):
          inverted_values.clear()
          x1, lp1 = self.evaluate(
              joint.experimental_sample_and_log_prob(
                  sample_shape, seed=seed, df=2.7
              )
          )  # Check that kwargs are supported.
          x2 = self.evaluate(
              joint.sample(sample_shape, seed=seed, df=2.7)
          )
          self.assertAllCloseNested(x1, x2)
  
          self.assertLen(inverted_values, 0)
          lp2 = joint.log_prob(x1)
          self.assertLen(inverted_values, 1)
          self.assertAllClose(lp1, lp2)
  
imports: import collections
  import os
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector_test_util
  from tensorflow_probability.python.bijectors import exp
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import deterministic
  from tensorflow_probability.python.distributions import dirichlet
  from tensorflow_probability.python.distributions import exponential
  from tensorflow_probability.python.distributions import half_normal
  from tensorflow_probability.python.distributions import inverse_gamma
  from tensorflow_probability.python.distributions import joint_distribution_auto_batched
  from tensorflow_probability.python.distributions import joint_distribution_coroutine
  from tensorflow_probability.python.distributions import joint_distribution_named
  from tensorflow_probability.python.distributions import joint_distribution_sequential
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.distributions import multinomial
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import poisson
  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.distributions import uniform
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.util import deferred_tensor
label_desc: Use image node_id 7 for calling the JointDistributionAutoBatchedTest obj's underlying member method code with example usage: obj.test_sample_and_log_prob(jd_class) and returns: tf