class_docstr: Tests the Autoregressive distribution.
class_docstr_tok: ["Tests","the","Autoregressive","distribution","."]
code: def testGradientsThroughParams(self):
      class DistFn(tf.Module):
          def __init__(self):
              self._w = tf.Variable([1.0, 1.0])
              self._b = tf.Variable([0.0, 0.0, 0.0])
  
          def __call__(self, sample=None):
              if sample is None:
                  sample = tf.convert_to_tensor([0.0, 0.0, 0.0])
              loc = tf.stack(
                  [
                      tf.broadcast_to(
                          self._b[0], shape=tf.shape(sample)[:-1]
                      ),
                      self._b[1]
                      + self._w[0] * sample[..., 0] * sample[..., 2],
                      self._b[2] + self._w[1] * sample[..., 0],
                  ],
                  axis=-1,
              )
              return independent.Independent(
                  normal.Normal(loc, 1.0), reinterpreted_batch_ndims=1
              )
  
      sample0 = tf.Variable([0.0, 0.0, 0.0])
      ar = autoregressive.Autoregressive(
          DistFn(), sample0=sample0, num_steps=3, validate_args=True
      )
  
      self.evaluate([v.initializer for v in ar.trainable_variables])
      with tf.GradientTape() as tape:
          loss = tf.reduce_sum(
              tf.square(ar.sample(seed=test_util.test_seed())), axis=-1
          )
      grad = tape.gradient(loss, ar.trainable_variables)
  
      self.assertLen(grad, 3)
      self.assertAllNotNone(grad)
  
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 12 for calling the AutoregressiveTest obj's underlying member method code with example usage: obj.testGradientsThroughParams() and returns: independent