code: def test_get_categorical_features_to_sampling(self):
      cat_example = tf.train.Example()
      cat_example.features.feature[
          "non_numeric"
      ].bytes_list.value.extend([b"cat"])
  
      cow_example = tf.train.Example()
      cow_example.features.feature[
          "non_numeric"
      ].bytes_list.value.extend([b"cow"])
  
      pony_example = tf.train.Example()
      pony_example.features.feature[
          "non_numeric"
      ].bytes_list.value.extend([b"pony"])
  
      examples = (
          [cat_example] * 4 + [cow_example] * 5 + [pony_example] * 10
      )
  
      # If we stop sampling at the first 3 examples, the only example should be
      # cat example.
      data = inference_utils.get_categorical_features_to_sampling(
          examples[0:3], top_k=1
      )
      self.assertDictEqual({"non_numeric": {"samples": ["cat"]}}, data)
  
      # If we sample more examples, the top 2 examples should be cow and pony.
      data = inference_utils.get_categorical_features_to_sampling(
          examples[0:20], top_k=2
      )
      self.assertDictEqual(
          {"non_numeric": {"samples": ["pony", "cow"]}}, data
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import sys
  import numpy
  import tensorflow
  from tensorflow_serving.apis import classification_pb2
  from tensorflow_serving.apis import predict_pb2
  from tensorflow_serving.apis import regression_pb2
  from utils import common_utils
  from utils import inference_utils
  from utils import platform_utils
  from utils import test_utils
label_desc: Use image node_id 12 for calling the InferenceUtilsTest obj's underlying member method code with example usage: obj.test_get_categorical_features_to_sampling() without return types