code: def generate_feature_partitions(
      sliced_record_batch: types.SlicedRecordBatch,
      partitioner: ColumnHasher,
      universal_features: FrozenSet[str],
  ) -> Iterable[Tuple[Tuple[types.SliceKey, int], pa.RecordBatch]]:
      """Partitions an input RecordBatch by feature name.
  
      The provided partitioner returns a value [0, k) deterministically for each
      feature name. Given an input containing multiple column names, up to k
      partitions are generated, with each partition containing the subset of
      features that were assigned by the provided partitioner to that value.
  
  
      Args:
        sliced_record_batch: An input RecordBatch. The slice-key of this input will
          be present in each output as part of the SliceKeyAndFeaturePartition.
        partitioner: A FeaturePartitioner instance.
        universal_features: Features that fall in every output partition.
  
      Yields:
        A sequence of partitions, each containing a subset of features.
      """
      slice_key = sliced_record_batch[0]
      partition_to_features = collections.defaultdict(
          lambda: ([], [])
      )  # type: Mapping[int, Any]
      # Arrange output columns normal, universal, with columns within each in their
      # original order.
      for column_name, column in zip(
          sliced_record_batch[1].schema.names,
          sliced_record_batch[1].columns,
      ):
          if column_name in universal_features:
              continue
          entry = partition_to_features[partitioner.assign(column_name)]
          entry[0].append(column_name)
          entry[1].append(column)
      for column_name, column in zip(
          sliced_record_batch[1].schema.names,
          sliced_record_batch[1].columns,
      ):
          if column_name not in universal_features:
              continue
          for partition in range(partitioner.num_partitions):
              entry = partition_to_features[partition]
              entry[0].append(column_name)
              entry[1].append(column)
  
      for partition, features in partition_to_features.items():
          key = (slice_key, partition)
          column_names, columns = features
          yield (key, pa.RecordBatch.from_arrays(columns, column_names))
  
file_path: data-validation/tensorflow_data_validation/utils/feature_partition_util.py
imports: import collections
  from typing import Any, FrozenSet, Iterable, Mapping, Tuple, Union
  import apache_beam
  import farmhash
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: generate_feature_partitions(sliced_record_batch, partitioner, universal_features) without return types