code: def testCovarianceFromSampling(self):
      if tf.executing_eagerly():
          raise unittest.SkipTest(
              "testCovarianceFromSampling is too slow to test in Eager mode"
          )
      # We will test mean, cov, var, stddev on a Multinomial constructed via
      # broadcast between alpha, n.
      theta = np.array([[1.0, 2, 3], [2.5, 4, 0.01]], dtype=np.float32)
      theta /= np.sum(theta, 1)[..., tf.newaxis]
      n = np.array(
          [[10.0, 9.0], [8.0, 7.0], [6.0, 5.0]], dtype=np.float32
      )
      # batch_shape=[3, 2], event_shape=[3]
      dist = multinomial.Multinomial(n, theta, validate_args=True)
      x = dist.sample(int(100e3), seed=test_util.test_seed())
      sample_mean = tf.reduce_mean(x, axis=0)
      x_centered = x - sample_mean[tf.newaxis, ...]
      sample_cov = tf.reduce_mean(
          tf.matmul(
              x_centered[..., tf.newaxis],
              x_centered[..., tf.newaxis, :],
          ),
          axis=0,
      )
      sample_var = tf.linalg.diag_part(sample_cov)
      sample_stddev = tf.sqrt(sample_var)
      [
          x_,
          sample_cov_,
          sample_var_,
          sample_stddev_,
          analytic_mean,
          analytic_cov,
          analytic_var,
          analytic_stddev,
      ] = self.evaluate(
          [
              x,
              sample_cov,
              sample_var,
              sample_stddev,
              dist.mean(),
              dist.covariance(),
              dist.variance(),
              dist.stddev(),
          ]
      )
      self.assertAllMeansClose(
          x_, analytic_mean, axis=0, atol=0.1, rtol=0.1
      )
      self.assertAllClose(sample_cov_, analytic_cov, atol=0.1, rtol=0.1)
      self.assertAllClose(sample_var_, analytic_var, atol=0.1, rtol=0.1)
      self.assertAllClose(
          sample_stddev_, analytic_stddev, atol=0.1, rtol=0.1
      )
  
imports: import unittest
  from absl.testing import parameterized
  import hypothesis
  from hypothesis import strategies
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.distributions import binomial
  from tensorflow_probability.python.distributions import hypothesis_testlib
  from tensorflow_probability.python.distributions import multinomial
  from tensorflow_probability.python.distributions.internal import statistical_testing
  from tensorflow_probability.python.internal import hypothesis_testlib
  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 MultinomialTest obj's underlying member method code with example usage: obj.testCovarianceFromSampling() without return types