code: def testCompareGradientToTfRandomGammaGradientWithNonLinearity(self):
      # Test that the gradient is correctly computed through a non-linearity.
  
      n_concentration = 4
      concentration_v = tf.constant(
          np.array(
              [np.arange(1, n_concentration + 1, dtype=np.float32)]
          )
      )
      n_rate = 2
      rate_v = tf.constant(
          np.array([np.arange(1, n_rate + 1, dtype=np.float32)]).T
      )
      num_samples = int(1e5)
  
      def tfp_exp_gamma(a, b):
          return tf.math.square(
              exp_gamma_lib.ExpGamma(
                  concentration=a, rate=b, validate_args=True
              ).sample(num_samples, seed=test_util.test_seed())
          )
  
      _, [grad_concentration, grad_rate] = self.evaluate(
          gradient.value_and_gradient(
              tfp_exp_gamma, [concentration_v, rate_v]
          )
      )
  
      def tf_exp_gamma(a, b):
          return tf.math.square(
              tf.math.log(
                  tf.random.gamma(
                      shape=[num_samples],
                      alpha=a,
                      beta=b,
                      seed=test_util.test_seed(),
                  )
              )
          )
  
      _, [grad_concentration_tf, grad_rate_tf] = self.evaluate(
          gradient.value_and_gradient(
              tf_exp_gamma, [concentration_v, rate_v]
          )
      )
  
      self.assertEqual(
          grad_concentration.shape, grad_concentration_tf.shape
      )
      self.assertEqual(grad_rate.shape, grad_rate_tf.shape)
      self.assertAllClose(
          grad_concentration, grad_concentration_tf, rtol=0.06
      )
      self.assertAllClose(grad_rate, grad_rate_tf, rtol=2e-2)
  
imports: from absl.testing import parameterized
  import numpy
  from scipy import misc
  from scipy import special
  from scipy import stats
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import exp
  from tensorflow_probability.python.distributions import exp_gamma
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions.internal import statistical_testing
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 16 for calling the ExpGammaTest obj's underlying member method code with example usage: obj.testCompareGradientToTfRandomGammaGradientWithNonLinearity() and returns: tf, tf