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","."]
docstr: Updates combined sketch with values (and weights if provided).
docstr_tok: ["Updates","combined","sketch","with","values","(","and","weights","if","provided",")","."]
code: def _update_combined_sketch_for_feature(
      self,
      feature_name: tfdv_types.FeaturePath,
      values: pa.Array,
      weights: Optional[np.ndarray],
      accumulator: Dict[tfdv_types.FeaturePath, _CombinedSketch],
  ):
      """Updates combined sketch with values (and weights if provided)."""
      flattened_values, parent_indices = array_util.flatten_nested(
          values, weights is not None
      )
  
      combined_sketch = accumulator.get(feature_name, None)
      if combined_sketch is None:
          self._num_kmv_buckets_gauge.update(self._num_kmv_buckets)
  
          def make_mg_sketch():
              num_buckets = max(
                  self._num_misragries_buckets,
                  self._num_top_values,
                  self._num_rank_histogram_buckets,
              )
              self._num_mg_buckets_gauge.update(num_buckets)
              self._num_top_values_gauge.update(self._num_top_values)
              self._num_rank_histogram_buckets_gauge.update(
                  self._num_rank_histogram_buckets
              )
              categorical = (
                  self._byte_feature_is_categorical_values.get(
                      feature_name,
                      schema_pb2.StringDomain.Categorical.CATEGORICAL_UNSPECIFIED,
                  )
                  == schema_pb2.StringDomain.Categorical.CATEGORICAL_YES
              )
              return MisraGriesSketch(
                  num_buckets=num_buckets,
                  invalid_utf8_placeholder=constants.NON_UTF8_PLACEHOLDER,
                  # Maximum sketch size:
                  # _LARGE_STRING_THRESHOLD * num_buckets * constant_factor.
                  large_string_threshold=_LARGE_STRING_THRESHOLD
                  if not categorical
                  else None,
                  large_string_placeholder=constants.LARGE_BYTES_PLACEHOLDER
                  if not categorical
                  else None,
              )
  
          self._num_top_values_gauge.update(self._num_top_values)
          combined_sketch = _CombinedSketch(
              distinct=KmvSketch(self._num_kmv_buckets),
              topk_unweighted=make_mg_sketch(),
              topk_weighted=make_mg_sketch(),
          )
      weight_array = None
      if weights is not None:
          flattened_weights = weights[parent_indices]
          weight_array = pa.array(flattened_weights, type=pa.float32())
      combined_sketch.add(flattened_values, weight_array)
      accumulator[feature_name] = combined_sketch
  
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 2 for calling the TopKUniquesSketchStatsGenerator obj's underlying member method code with example usage: obj._update_combined_sketch_for_feature(feature_name, values, weights, accumulator) and returns: MisraGriesSketch