code: def testDirichletDirichletKL(self):
      conc1 = np.array(
          [
              [1.0, 2.0, 3.0, 1.5, 2.5, 3.5],
              [1.5, 2.5, 3.5, 4.5, 5.5, 6.5],
          ]
      )
      conc2 = np.array([[0.5, 1.0, 1.5, 2.0, 2.5, 3.0]])
  
      d1 = dirichlet.Dirichlet(conc1)
      d2 = dirichlet.Dirichlet(conc2)
      x = d1.sample(int(1e4), seed=test_util.test_seed())
      kl_samples = d1.log_prob(x) - d2.log_prob(x)
      kl_actual = kullback_leibler.kl_divergence(d1, d2)
  
      kl_samples_ = self.evaluate(kl_samples)
      kl_actual_val = self.evaluate(kl_actual)
  
      self.assertEqual(conc1.shape[:-1], kl_actual.shape)
  
      kl_expected = (
          sp_special.gammaln(np.sum(conc1, -1))
          - sp_special.gammaln(np.sum(conc2, -1))
          - np.sum(
              sp_special.gammaln(conc1) - sp_special.gammaln(conc2), -1
          )
          + np.sum(
              (conc1 - conc2)
              * (
                  sp_special.digamma(conc1)
                  - sp_special.digamma(np.sum(conc1, -1, keepdims=True))
              ),
              -1,
          )
      )
  
      self.assertAllClose(
          kl_expected, kl_actual_val, atol=0.0, rtol=1e-5
      )
      self.assertAllMeansClose(
          kl_samples_, kl_actual_val, axis=0, atol=0.0, rtol=1e-1
      )
  
      # Make sure KL(d1||d1) is 0
      kl_same = self.evaluate(kullback_leibler.kl_divergence(d1, d1))
      self.assertAllClose(kl_same, np.zeros_like(kl_expected))
  
imports: import numpy
  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 dirichlet
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.util import deferred_tensor
label_desc: Use image node_id 23 for calling the DirichletTest obj's underlying member method code with example usage: obj.testDirichletDirichletKL() without return types