code: def testAutoregression(self):
      inputs = self._make_input_layers()
      dist = self._make_pixel_cnn()
  
      if isinstance(inputs, list):
          log_prob = dist.log_prob(
              inputs[0], conditional_input=inputs[1]
          )
      else:
          log_prob = dist.log_prob(inputs)
  
      # Build/fit a model to activate autoregressive kernel constraints
      model = tf_keras.Model(inputs=inputs, outputs=log_prob)
      model.add_loss(-tf.reduce_mean(log_prob))
  
      model.compile()
      if not tf.executing_eagerly() and isinstance(
          model.optimizer, tf_keras.optimizers.experimental.Optimizer
      ):
          return
      train_data = self._make_fake_inputs()
      model.fit(x=train_data)
  
      ### Test gradients of logistic means
      i, j = 2, 3
      pixel_ind = (0, i, j, 0, 1)
      grads = self._get_single_pixel_logit_gradients(dist, 1, pixel_ind)
      self._grads_assertions(grads, i, j)
  
      # Since we're testing a green pixel: Gradients wrt the green and blue
      # components of the input pixel are 0
      self.assertEqual((grads[0][i][j][1:] != 0.0).sum(), 0)
  
      # Gradients with respect to the red pixel are nonzero
      self.assertNotEqual(grads[0][i][j][0], 0)
  
      ### Test gradients of logistic scales
      i, j = 2, 2
      pixel_ind = (0, i, j, 0, 1)
      grads = self._get_single_pixel_logit_gradients(dist, 2, pixel_ind)
      self._grads_assertions(grads, i, j)
  
      ### Test gradients of mixture components
      i, j = 3, 3
      pixel_ind = (0, i, j, 0)
      grads = self._get_single_pixel_logit_gradients(dist, 0, pixel_ind)
      self._grads_assertions(grads, i, j)
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import pixel_cnn
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 12 for calling the PixelCnnTest obj's underlying member method code with example usage: obj.testAutoregression() without return types