code: def testCovarianceNAlphaBroadcast(self):
      alpha_v = [1.0, 2, 3]
      alpha_0 = 6.0
  
      # Shape [4, 3]
      alpha = np.array(4 * [alpha_v], dtype=np.float32)
      # Shape [4]
      ns = np.array([2.0, 3.0, 4.0, 5.0], dtype=np.float32)
  
      variance_entry = lambda a, a_sum: a / a_sum * (1 - a / a_sum)
      covariance_entry = lambda a, b, a_sum: -a * b / a_sum**2
      # Shape [4, 3, 3]
      shared_matrix = np.array(
          4
          * [
              [
                  [
                      variance_entry(alpha_v[0], alpha_0),
                      covariance_entry(alpha_v[0], alpha_v[1], alpha_0),
                      covariance_entry(alpha_v[0], alpha_v[2], alpha_0),
                  ],
                  [
                      covariance_entry(alpha_v[1], alpha_v[0], alpha_0),
                      variance_entry(alpha_v[1], alpha_0),
                      covariance_entry(alpha_v[1], alpha_v[2], alpha_0),
                  ],
                  [
                      covariance_entry(alpha_v[2], alpha_v[0], alpha_0),
                      covariance_entry(alpha_v[2], alpha_v[1], alpha_0),
                      variance_entry(alpha_v[2], alpha_0),
                  ],
              ]
          ],
          dtype=np.float32,
      )
  
      # ns is shape [4], and alpha is shape [4, 3].
      dist = dm.DirichletMultinomial(ns, alpha, validate_args=True)
      covariance = dist.covariance()
      expected_covariance = (
          shared_matrix
          * (ns * (ns + alpha_0) / (1 + alpha_0))[
              ..., tf.newaxis, tf.newaxis
          ]
      )
  
      self.assertEqual([4, 3, 3], covariance.shape)
      self.assertAllClose(
          expected_covariance, self.evaluate(covariance)
      )
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import dirichlet_multinomial
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 19 for calling the DirichletMultinomialTest obj's underlying member method code with example usage: obj.testCovarianceNAlphaBroadcast() without return types