class_docstr: Tests for TopKUniquesSketchStatsGenerator.
class_docstr_tok: ["Tests","for","TopKUniquesSketchStatsGenerator","."]
code: def test_topk_uniques_sketch_with_categorical_numeric_feature(
      self, is_float
  ):
      # fa: 4 12, 2 23, 2 34, 2 45
      def _map_nested_list(fn, val):
          if isinstance(val, list):
              return list([_map_nested_list(fn, v) for v in val])
          return fn(val)
  
      data = [[[12, 23, 34, 12], [45, 23]], [[12, 12, 34, 45]]]
      if is_float == "float":
          data = _map_nested_list(float, data)
          type_enum = "FLOAT"
          domain = "float_domain"
      else:
          type_enum = "INT"
          domain = "int_domain"
      batches = [
          pa.RecordBatch.from_arrays([pa.array(data[0])], ["fa"]),
          pa.RecordBatch.from_arrays([pa.array(data[1])], ["fa"]),
      ]
  
      expected_result = {
          types.FeaturePath(["fa"]): text_format.Parse(
              """
                  path {
                    step: 'fa'
                  }
                  string_stats {
                    unique: 4
                    top_values {
                      value: '12'
                      frequency: 4
                    }
                    top_values {
                      value: '45'
                      frequency: 2
                    }
                    top_values {
                      value: '34'
                      frequency: 2
                    }
                    top_values {
                      value: '23'
                      frequency: 2
                    }
                    rank_histogram {
                      buckets {
                        low_rank: 0
                        high_rank: 0
                        label: "12"
                        sample_count: 4.0
                      }
                      buckets {
                        low_rank: 1
                        high_rank: 1
                        label: "45"
                        sample_count: 2.0
                      }
                      buckets {
                        low_rank: 2
                        high_rank: 2
                        label: "34"
                        sample_count: 2.0
                      }
                    }
                }""",
              statistics_pb2.FeatureNameStatistics(),
          )
      }
  
      schema = text_format.Parse(
          """
          feature {
            name: "fa"
            type: %s
            %s {
              is_categorical: true
            }
          }
          """
          % (type_enum, domain),
          schema_pb2.Schema(),
      )
      generator = sketch_generator.TopKUniquesSketchStatsGenerator(
          schema=schema, num_top_values=4, num_rank_histogram_buckets=3
      )
      self.assertCombinerOutputEqual(
          batches, generator, expected_result
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import absltest
  from absl.testing import parameterized
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import top_k_uniques_sketch_stats_generator
  from tensorflow_data_validation.utils import test_util
  from tensorflow_data_validation.utils.example_weight_map import ExampleWeightMap
  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 9 for calling the TopKUniquesSketchStatsGeneratorTest obj's underlying member method code with example usage: obj.test_topk_uniques_sketch_with_categorical_numeric_feature(is_float) and returns: fn, list