code: def testCategorical(self):
      np.random.seed(3)
      a = np.array(
          [b"cat0"] * 2000
          + [b"cat1"] * 2000
          + [b"cat2"] * 2000
          + [b"\xc5\x8cmura"] * 2000
      )  # 4 categories
      b = np.random.randn(a.size)
      c = np.arange(0.1, 100, 0.001)[: a.size] + 2 * b
      d = (
          np.random.normal(0.5, 1.0, a.size)
          + np.random.normal(-0.5, 1.0, a.size)
          + np.random.normal(0.0, 0.3, a.size)
      )
      e = np.arange(0.1, 100, 0.001)[: a.size]
      # Build some features that repeat N times the same value sequence.
      g = np.array([i // (a.size // 8) for i in range(a.size)])
      h = np.array(
          [b"cat%d" % (i // (a.size // 16)) for i in range(a.size)]
      )
  
      for method in ["smaller_data", "larger_data"]:
          result = _MI(
              [b],
              [a],
              [False],
              [True],
              k=6,
              estimate_method=method,
              seed=20,
          )
          self.assertLess(abs(result), 2e-2)
  
          result = _MI(
              [c],
              [a],
              [False],
              [True],
              k=6,
              estimate_method=method,
              seed=20,
          )
          self.assertAlmostEqual(result, 0.565, delta=1e2)
  
          result = _MI(
              [d],
              [a],
              [False],
              [True],
              k=6,
              estimate_method=method,
              seed=20,
          )
          self.assertLess(abs(result), 1e-2)
  
          result = _MI(
              [e],
              [h],
              [False],
              [True],
              k=6,
              estimate_method=method,
              seed=20,
          )
          self.assertAlmostEqual(result, 4, delta=1e2)
  
          result = _MI(
              [g],
              [h],
              [False],
              [True],
              k=6,
              estimate_method=method,
              seed=20,
          )
          self.assertAlmostEqual(result, 3, delta=1e2)
  
          result = _MI(
              [a, b],
              [b, a],
              [True, False],
              [False, True],
              estimate_method=method,
              seed=20,
          )
          self.assertAlmostEqual(result, 13.15, delta=1e2)
  
imports: from absl.testing import absltest
  from absl.testing import parameterized
  import numpy
  from tensorflow_data_validation.utils import mutual_information_util
label_desc: Use image node_id 12 for calling the RanklabMutualInformationTest obj's underlying member method code with example usage: obj.testCategorical() without return types