class_docstr: Generates statistics for number unique and top-k item counts.
  
  Uses mergeable K-Minimum Values (KMV) and Misra-Gries sketches to estimate
  statistics.
class_docstr_tok: ["Generates","statistics","for","number","unique","and","top-k","item","counts",".","Uses","mergeable","K-Minimum","Values","(","KMV",")","and","Misra-Gries","sketches","to","estimate","statistics","."]
code: def add_input(
      self,
      accumulator: Dict[tfdv_types.FeaturePath, _CombinedSketch],
      input_record_batch: pa.RecordBatch,
  ) -> Dict[tfdv_types.FeaturePath, _CombinedSketch]:
      def update_length_counters(
          feature_type: tfdv_types.FeatureNameStatisticsType,
          leaf_array: pa.Array,
      ):
          if np.random.random() > self._length_counter_sampling_rate:
              return
          if (
              feature_type
              == statistics_pb2.FeatureNameStatistics.STRING
          ):
              distinct_count = collections.defaultdict(int)
              values, _ = array_util.flatten_nested(leaf_array)
              for value in values:
                  binary_scalar_len = int(
                      np.log2(max(value.as_buffer().size, 1))
                  )
                  distinct_count[binary_scalar_len] += 1
              for k, v in distinct_count.items():
                  beam.metrics.Metrics.counter(
                      constants.METRICS_NAMESPACE,
                      "binary_scalar_len_" + str(k),
                  ).inc(v)
  
      for (
          feature_path,
          leaf_array,
          weights,
      ) in arrow_util.enumerate_arrays(
          input_record_batch,
          example_weight_map=self._example_weight_map,
          enumerate_leaves_only=True,
      ):
          feature_type = stats_util.get_feature_type_from_arrow_type(
              feature_path, leaf_array.type
          )
          if self._should_run(feature_path, feature_type):
              self._update_combined_sketch_for_feature(
                  feature_path, leaf_array, weights, accumulator
              )
              update_length_counters(feature_type, leaf_array)
      return accumulator
  
imports: import collections
  from typing import Dict, Iterable, Optional, Text
  import apache_beam
  import numpy
  import pyarrow
  from tensorflow_data_validation import constants
  from tensorflow_data_validation import types
  from tensorflow_data_validation.arrow import arrow_util
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow_data_validation.utils import schema_util
  from tensorflow_data_validation.utils import stats_util
  from tensorflow_data_validation.utils import top_k_uniques_stats_util
  from tensorflow_data_validation.utils.example_weight_map import ExampleWeightMap
  from tfx_bsl.arrow import array_util
  from tfx_bsl.sketches import KmvSketch
  from tfx_bsl.sketches import MisraGriesSketch
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 5 for calling the TopKUniquesSketchStatsGenerator obj's underlying member method code with example usage: obj.add_input(accumulator, input_record_batch) and returns: accumulator