code: def testSample(self):
      num_samples = 2
      h = self._make_fake_conditional()
  
      # Weight normalization and data-dependent initialization work only in Eager
      # so we enable them only if executing eagerly. We use them only in this
      # test, since they add significantly to run time, and using them in
      # additional tests wouldn't meaningfully increase coverage.
      dist = self._make_pixel_cnn(
          use_weight_norm_and_data_init=tf.executing_eagerly()
      )
      self.evaluate([v.initializer for v in dist.network.weights])
      sample_shape = (
          (num_samples,)
          if h is None
          else (num_samples,) + self.batch_shape
      )
      samples = self.evaluate(
          dist.sample(sample_shape, conditional_input=h)
      )
  
      self.assertAllEqual(
          sample_shape + self.image_shape,
          self.evaluate(tf.shape(samples)),
      )
      self.assertAllInRange(samples, self.low, self.high)
      self.assertLessEqual(np.unique(samples).size, self.high + 1)
  
      seed = test_util.test_seed()
      if tf.executing_eagerly():
          tf.random.set_seed(seed)
      sample_rng_1 = dist.sample(
          self.batch_shape, conditional_input=h, seed=seed
      )
      if tf.executing_eagerly():
          tf.random.set_seed(seed)
      sample_rng_2 = dist.sample(
          self.batch_shape, conditional_input=h, seed=seed
      )
      self.assertAllEqual(
          self.evaluate(sample_rng_1), self.evaluate(sample_rng_2)
      )
  
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 11 for calling the PixelCnnTest obj's underlying member method code with example usage: obj.testSample() without return types