code: def testSamplingCorrectness(self):
      np.random.seed(1618)  # Make it reproducible.
      num_samples = 21000
  
      rand_probs = self._normalize(np.random.random_sample((10,)))
      rand_probs2 = self._normalize(
          np.random.random_sample((3, 5))
      )  # batched
      for probs in [
          [0.5, 0.5],
          [0.85, 0.05, 0.1],
          rand_probs,
          rand_probs2,
      ]:
          probs = np.asarray(probs)
          if len(probs.shape) == 1:
              probs = probs.reshape(1, probs.size)  # singleton batch
  
          logits = np.log(probs).astype(np.float32)
          composed_freqs = self._do_sampling(
              logits, num_samples, composed_sampler
          )
          native_freqs = self._do_sampling(
              logits, num_samples, native_sampler
          )
  
          # the test here is similar to core/lib/random/distribution_sampler_test.cc
          composed_chi2 = self._chi2(probs, composed_freqs)
          native_chi2 = self._chi2(probs, native_freqs)
          composed_native_chi2 = self._chi2(
              composed_freqs, native_freqs
          )
  
          def check(chi2s):
              for chi2 in chi2s:
                  self.assertLess(chi2, 1e-3)
  
          check(composed_chi2)
          check(native_chi2)
          check(composed_native_chi2)
  
imports: import collections
  import timeit
  import numpy
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 9 for calling the MultinomialTest obj's underlying member method code with example usage: obj.testSamplingCorrectness() without return types