code: def testCategoricalCategoricalKL(self):
      def np_softmax(logits):
          exp_logits = np.exp(logits)
          return exp_logits / exp_logits.sum(axis=-1, keepdims=True)
  
      for categories in [2, 10]:
          for batch_size in [1, 2]:
              p_logits = self._rng.random_sample(
                  (batch_size, categories)
              )
              q_logits = self._rng.random_sample(
                  (batch_size, categories)
              )
              p = oc.OneHotCategorical(
                  logits=p_logits, validate_args=True
              )
              q = oc.OneHotCategorical(
                  logits=q_logits, validate_args=True
              )
              prob_p = np_softmax(p_logits)
              prob_q = np_softmax(q_logits)
              kl_expected = np.sum(
                  prob_p * (np.log(prob_p) - np.log(prob_q)), axis=-1
              )
  
              kl_actual = kullback_leibler.kl_divergence(p, q)
              kl_same = kullback_leibler.kl_divergence(p, p)
              x = p.sample(int(2e4), seed=test_util.test_seed())
              x = tf.cast(x, dtype=tf.float32)
              # Compute empirical KL(p||q).
              kl_samples = p.log_prob(x) - q.log_prob(x)
  
              [kl_samples_, kl_actual_, kl_same_] = self.evaluate(
                  [kl_samples, kl_actual, kl_same]
              )
              self.assertEqual(kl_actual.shape, (batch_size,))
              self.assertAllClose(kl_same_, np.zeros_like(kl_expected))
              self.assertAllClose(
                  kl_actual_, kl_expected, atol=0.0, rtol=1e-4
              )
              self.assertAllMeansClose(
                  kl_samples_, kl_expected, axis=0, atol=1e-2, rtol=0.0
              )
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import onehot_categorical
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.util import deferred_tensor
label_desc: Use image node_id 16 for calling the OneHotCategoricalTest obj's underlying member method code with example usage: obj.testCategoricalCategoricalKL() and returns: unknown