code: def testGammaGammaKL(self):
      concentration0 = np.array([3.0])
      rate0 = np.array([1.0, 2.0, 3.0, 1.5, 2.5, 3.5])
  
      concentration1 = np.array([0.4])
      rate1 = np.array([0.5, 1.0, 1.5, 2.0, 2.5, 3.0])
  
      # Build graph.
      g0 = gamma_lib.Gamma(
          concentration=concentration0, rate=rate0, validate_args=True
      )
      g0lr = gamma_lib.Gamma(
          concentration=concentration0,
          log_rate=np.log(rate0),
          validate_args=True,
      )
      g1 = gamma_lib.Gamma(
          concentration=concentration1, rate=rate1, validate_args=True
      )
      g1lr = gamma_lib.Gamma(
          concentration=concentration1,
          log_rate=np.log(rate1),
          validate_args=True,
      )
  
      for d0, d1 in (g0, g1), (g0lr, g1), (g0, g1lr), (g0lr, g1lr):
          x = d0.sample(int(1e4), seed=test_util.test_seed())
          kl_samples = d0.log_prob(x) - d1.log_prob(x)
          kl_actual = kullback_leibler.kl_divergence(d0, d1)
  
          # Execute graph.
          [kl_samples_, kl_actual_] = self.evaluate(
              [kl_samples, kl_actual]
          )
  
          self.assertEqual(rate0.shape, kl_actual.shape)
  
          kl_expected = (
              (concentration0 - concentration1)
              * sp_special.digamma(concentration0)
              + sp_special.gammaln(concentration1)
              - sp_special.gammaln(concentration0)
              + concentration1 * np.log(rate0)
              - concentration1 * np.log(rate1)
              + concentration0 * (rate1 / rate0 - 1.0)
          )
  
          self.assertAllClose(
              kl_expected, kl_actual_, atol=0.0, rtol=1e-6
          )
          self.assertAllMeansClose(
              kl_samples_, kl_actual_, axis=0, atol=0.0, rtol=1e-1
          )
  
imports: import functools
  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 gamma
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions.internal import statistical_testing
  from tensorflow_probability.python.internal import implementation_selection
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 28 for calling the GammaTest obj's underlying member method code with example usage: obj.testGammaGammaKL() without return types