class_docstr: Tests the Autoregressive distribution.
class_docstr_tok: ["Tests","the","Autoregressive","distribution","."]
code: def testVariableNumStepsAndEventShape(self):
      loc = tf.Variable(np.zeros((4, 2)), shape=tf.TensorShape(None))
      event_ndims = tf.Variable(1)
  
      def fn(sample=None):
          if sample is not None:
              loc_param = tf.broadcast_to(loc, shape=tf.shape(sample))
          else:
              loc_param = loc
          return independent.Independent(
              normal.Normal(loc=loc_param, scale=1.0),
              reinterpreted_batch_ndims=event_ndims,
          )
  
      num_steps = tf.Variable(7)
      self.evaluate(
          [v.initializer for v in [loc, num_steps, event_ndims]]
      )
  
      ar = autoregressive.Autoregressive(
          fn, num_steps=num_steps, validate_args=True
      )
      sample = self.evaluate(ar.sample(3, seed=test_util.test_seed()))
      self.assertAllEqual([3, 4, 2], sample.shape)
      self.assertAllEqual([2], self.evaluate(ar.event_shape_tensor()))
      self.assertAllEqual([4], self.evaluate(ar.batch_shape_tensor()))
  
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 8 for calling the AutoregressiveTest obj's underlying member method code with example usage: obj.testVariableNumStepsAndEventShape() and returns: independent