class_docstr: Tests the Autoregressive distribution.
class_docstr_tok: ["Tests","the","Autoregressive","distribution","."]
code: def testBatchAndEventShape(self):
      loc = tf.Variable(np.zeros((5, 1, 3)), shape=tf.TensorShape(None))
      event_ndims = tf.Variable(2)
  
      def fn(sample):
          return independent.Independent(
              normal.Normal(loc=loc + 0.0 * sample, scale=1.0),
              reinterpreted_batch_ndims=tf.convert_to_tensor(
                  event_ndims
              ),
          )
  
      self.evaluate([v.initializer for v in [loc, event_ndims]])
  
      zero = tf.convert_to_tensor(0.0, dtype=loc.dtype)
      ar = autoregressive.Autoregressive(
          fn, num_steps=7, sample0=zero, validate_args=True
      )
  
      # NOTE: `ar.event_shape` and `ar.batch_shape` are not known statically,
      # even though the output of `ar.distribution_fn(...)` has statically-known
      # event shape and batch shape.
      self.assertEqual(ar.batch_shape, tf.TensorShape(None))
      self.assertEqual(ar.event_shape, tf.TensorShape(None))
      self.assertAllEqual([5], self.evaluate(ar.batch_shape_tensor()))
      self.assertAllEqual(
          [1, 3], self.evaluate(ar.event_shape_tensor())
      )
      if tf.executing_eagerly():
          self.assertEqual(
              tf.TensorShape([5]), ar.distribution_fn(zero).batch_shape
          )
          self.assertEqual(
              tf.TensorShape([1, 3]),
              ar.distribution_fn(zero).event_shape,
          )
  
      with tf.control_dependencies(
          [loc.assign(np.zeros((4, 7))), event_ndims.assign(1)]
      ):
          self.assertAllEqual(
              [4], self.evaluate(ar.batch_shape_tensor())
          )
          self.assertAllEqual(
              [7], self.evaluate(ar.event_shape_tensor())
          )
          if tf.executing_eagerly():
              self.assertEqual(
                  tf.TensorShape([4]),
                  ar.distribution_fn(zero).batch_shape,
              )
              self.assertEqual(
                  tf.TensorShape([7]),
                  ar.distribution_fn(zero).event_shape,
              )
  
imports: import warnings
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import masked_autoregressive
  from tensorflow_probability.python.bijectors import scale_matvec_tril
  from tensorflow_probability.python.distributions import autoregressive
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import sample
  from tensorflow_probability.python.distributions import transformed_distribution
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import linalg
label_desc: Use image node_id 9 for calling the AutoregressiveTest obj's underlying member method code with example usage: obj.testBatchAndEventShape() and returns: independent