code: def testChi2Chi2KL(self):
      a_df = np.arange(1.0, 10.0)
      b_df = np.arange(1.0, 10.0)
  
      # This reshape is intended to expand the number of test cases.
      a_df = a_df.reshape((len(a_df), 1))
      b_df = b_df.reshape((1, len(b_df)))
  
      a = chi2.Chi2(df=a_df, validate_args=True)
      b = chi2.Chi2(df=b_df, validate_args=True)
  
      # Consistent with
      # http://www.mast.queensu.ca/~communications/Papers/gil-msc11.pdf, page 110
      true_kl = (
          special.gammaln(b_df / 2.0)
          - special.gammaln(a_df / 2.0)
          + (a_df - b_df) / 2.0 * special.digamma(a_df / 2.0)
      )
  
      kl = kullback_leibler.kl_divergence(a, b)
  
      x = a.sample(int(1e5), seed=test_util.test_seed())
      kl_samples = a.log_prob(x) - b.log_prob(x)
  
      kl_, kl_samples_ = self.evaluate([kl, kl_samples])
      self.assertAllClose(kl_, true_kl, atol=0.0, rtol=5e-13)
      self.assertAllMeansClose(
          kl_samples_, true_kl, axis=0, atol=0.0, rtol=0.08
      )
  
      zero_kl = kullback_leibler.kl_divergence(a, a)
      true_zero_kl_, zero_kl_ = self.evaluate(
          [tf.zeros_like(zero_kl), zero_kl]
      )
      self.assertAllEqual(true_zero_kl_, zero_kl_)
  
imports: import numpy
  from scipy import special
  from scipy import stats
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import chi2
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 9 for calling the Chi2Test obj's underlying member method code with example usage: obj.testChi2Chi2KL() without return types