class_docstr: A combiner statistics generator that computes cross feature statistics.
    
class_docstr_tok: ["A","combiner","statistics","generator","that","computes","cross","feature","statistics","."]
docstr: Extracts univalent values for each feature along with parent indices.
docstr_tok: ["Extracts","univalent","values","for","each","feature","along","with","parent","indices","."]
code: def _get_univalent_values_with_parent_indices(
      self, examples: pa.RecordBatch
  ) -> Dict[types.FeatureName, DataFrame]:
      """Extracts univalent values for each feature along with parent indices."""
      result = {}
      for feature_name, feat_arr in zip(
          examples.schema.names, examples.columns
      ):
          if (
              self._features_needed is not None
              and feature_name not in self._features_needed
          ):
              continue
          feature_type = stats_util.get_feature_type_from_arrow_type(
              feature_name, feat_arr.type
          )
          # Only consider crosses of numeric features.
          # TODO(zhuo): Support numeric features nested under structs.
          if feature_type in (
              None,
              statistics_pb2.FeatureNameStatistics.STRING,
              statistics_pb2.FeatureNameStatistics.STRUCT,
          ):
              continue
          value_lengths = np.asarray(
              array_util.ListLengthsFromListArray(feat_arr)
          )
          univalent_parent_indices = set(
              (value_lengths == 1).nonzero()[0]
          )
          # If there are no univalent values, continue to the next feature.
          if not univalent_parent_indices:
              continue
          flattened, value_parent_indices = array_util.flatten_nested(
              feat_arr, True
          )
          non_missing_values = np.asarray(flattened)
          if feature_type == statistics_pb2.FeatureNameStatistics.FLOAT:
              # Remove any NaN values if present.
              non_nan_mask = ~np.isnan(non_missing_values)
              non_missing_values = non_missing_values[non_nan_mask]
              value_parent_indices = value_parent_indices[non_nan_mask]
          df = pd.DataFrame(
              {
                  feature_name: non_missing_values,
                  "parent_index": value_parent_indices,
              }
          )
          # Only keep the univalent feature values.
          df = df[df["parent_index"].isin(univalent_parent_indices)]
  
          result[feature_name] = df
  
      return result
  
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 3 for calling the CrossFeatureStatsGenerator obj's underlying member method code with example usage: obj._get_univalent_values_with_parent_indices(examples) and returns: result