code: def test_scalar_variate_sample_and_log_prob(self):
      if tf.executing_eagerly():
          # TODO(b/122840816): Modify this test so that it runs in eager mode or
          # document that the test is not intended to run in eager mode.
          return
  
      seed = test_util.test_seed(sampler_type="stateless")
  
      new_batch_shape = [2, 2]
      old_batch_shape = [4]
  
      normal, reshape_normal = self.make_normal(
          new_batch_shape, old_batch_shape
      )
  
      batch_shape = reshape_normal.batch_shape_tensor()
      event_shape = reshape_normal.event_shape_tensor()
  
      expected_sample_shape = new_batch_shape
      x = normal.sample(seed=seed)
      expected_sample = tf.reshape(x, expected_sample_shape)
      actual_sample = reshape_normal.sample(seed=seed)
  
      expected_log_prob_shape = new_batch_shape
      expected_log_prob = tf.reshape(
          normal.log_prob(x), expected_log_prob_shape
      )
      actual_log_prob = reshape_normal.log_prob(expected_sample)
  
      self.assertAllEqual(new_batch_shape, batch_shape)
      self.assertAllEqual([], event_shape)
      self.assertAllClose(
          expected_sample, actual_sample, atol=0.0, rtol=1e-6
      )
      self.assertAllClose(
          expected_log_prob, actual_log_prob, atol=0.0, rtol=1e-6
      )
  
      (
          slp_sample,
          slp_lp,
      ) = reshape_normal.experimental_sample_and_log_prob(seed=seed)
      self.assertAllClose(
          expected_sample, slp_sample, atol=0.0, rtol=1e-6
      )
      self.assertAllClose(
          expected_log_prob, slp_lp, atol=0.0, rtol=1e-6
      )
      if not self.is_static_shape:
          return
      self.assertAllEqual(new_batch_shape, reshape_normal.batch_shape)
      self.assertAllEqual([], reshape_normal.event_shape)
      self.assertAllEqual(expected_sample_shape, actual_sample.shape)
      self.assertAllEqual(
          expected_log_prob_shape, actual_log_prob.shape
      )
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector_test_util
  from tensorflow_probability.python.distributions import batch_reshape
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.distributions import triangular
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.distributions import wishart
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.util.deferred_tensor import DeferredTensor
label_desc: Use image node_id 5 for calling the _BatchReshapeTest obj's underlying member method code with example usage: obj.test_scalar_variate_sample_and_log_prob() without return types