code: def get_anomalies_slicer(
      anomalies: anomalies_pb2.Anomalies,
  ) -> types.SliceFunction:
      """Returns a SliceFunction that For each anomaly, yields (anomaly, example).
  
      Args:
        anomalies: An Anomalies proto from which to generate the list of slice keys.
      """
  
      def slice_fn(
          example: pa.RecordBatch,
      ) -> Iterable[types.SlicedRecordBatch]:
          for (
              feature_name,
              anomaly_info,
          ) in anomalies.anomaly_info.items():
              for anomaly_reason in anomaly_info.reason:
                  yield (
                      feature_name
                      + "_"
                      + anomalies_pb2.AnomalyInfo.Type.Name(
                          anomaly_reason.type
                      ),
                      example,
                  )
  
      return slice_fn
  
file_path: data-validation/tensorflow_data_validation/utils/anomalies_util.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Iterable, FrozenSet, List, Text, Tuple
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.utils import io_util
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import anomalies_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: get_anomalies_slicer(anomalies) and returns: slice_fn