code: def test_make_feature_stats_proto_topk_uniques_categorical(self):
      expected_result = text_format.Parse(
          """
          path {
            step: 'fa'
          }
          string_stats {
            unique: 4
            top_values {
              value: 'a'
              frequency: 4
            }
            top_values {
              value: 'c'
              frequency: 3
            }
            top_values {
              value: 'd'
              frequency: 2
            }
            rank_histogram {
              buckets {
                low_rank: 0
                high_rank: 0
                label: "a"
                sample_count: 4.0
              }
              buckets {
                low_rank: 1
                high_rank: 1
                label: "c"
                sample_count: 3.0
              }
            }
      }""",
          statistics_pb2.FeatureNameStatistics(),
      )
  
      value_counts = [("d", 2), ("c", 3), ("a", 4), ("b", 2)]
      top_k_value_count_list = [
          top_k_uniques_stats_util.FeatureValueCount(
              value_count[0], value_count[1]
          )
          for value_count in value_counts
      ]
      result = top_k_uniques_stats_util.make_feature_stats_proto_topk_uniques(
          types.FeaturePath(["fa"]),
          num_top_values=3,
          frequency_threshold=1,
          num_rank_histogram_buckets=2,
          num_unique=4,
          value_count_list=top_k_value_count_list,
      )
      test_util.assert_feature_proto_equal(
          self, result, expected_result
      )
  
file_path: data-validation/tensorflow_data_validation/utils/top_k_uniques_stats_util_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import absltest
  from tensorflow_data_validation import types
  from tensorflow_data_validation.utils import test_util
  from tensorflow_data_validation.utils import top_k_uniques_stats_util
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 3 for calling the TopKUniquesStatsUtilTest obj's underlying member method code with example usage: obj.test_make_feature_stats_proto_topk_uniques_categorical() without return types