class_docstr: A combiner statistics generator that computes cross feature statistics.
    
class_docstr_tok: ["A","combiner","statistics","generator","that","computes","cross","feature","statistics","."]
code: def add_input(
      self,
      accumulator: CrossFeatureStatsGeneratorAccumulator,
      examples: pa.RecordBatch,
  ) -> Dict[types.FeatureCross, _PartialCrossFeatureStats]:
      if random.random() > self._sample_rate:
          return accumulator
      # Cache the values and parent indices for each feature. We cache this to
      # avoid doing the same computation for a feature multiple times in
      # each cross.
      features_for_cross = (
          self._get_univalent_values_with_parent_indices(examples)
      )
  
      # Generate crosses of numeric univalent features and update the partial
      # cross stats.
      if self._feature_crosses is not None:
          feature_crosses = self._feature_crosses
      else:
          feature_crosses = itertools.combinations(
              sorted(list(features_for_cross.keys())), 2
          )
      for feat_name_x, feat_name_y in feature_crosses:
          feat_cross = (feat_name_x, feat_name_y)
          if feat_cross not in accumulator:
              accumulator[feat_cross] = _PartialCrossFeatureStats()
          df_x, df_y = (
              features_for_cross[feat_name_x],
              features_for_cross[feat_name_y],
          )
          # Join based on parent index so that we have the value pairs
          # corresponding to each example.
          merged_df = pd.merge(df_x, df_y, on="parent_index")
          # Update the partial cross stats.
          accumulator[feat_cross].update(
              merged_df[feat_name_x], merged_df[feat_name_y]
          )
  
      return accumulator
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  import math
  import random
  from typing import Dict, Iterable, List, Optional, Text
  import numpy
  import pandas
  from pandas import DataFrame, Series
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow_data_validation.utils import stats_util
  from tfx_bsl.arrow import array_util
  from tensorflow_metadata.proto.v0 import path_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 4 for calling the CrossFeatureStatsGenerator obj's underlying member method code with example usage: obj.add_input(accumulator, examples) and returns: accumulator, accumulator