code: def _ExtractLabels(
      extracts: beam.pvalue.PCollection,
      eval_config: config_pb2.EvalConfig,
  ) -> beam.pvalue.PCollection:
      """Extracts labels from features extracts.
  
      Args:
        extracts: PCollection containing features under tfma.FEATURES_KEY.
        eval_config: Eval config.
  
      Returns:
        PCollection of extracts with additional labels added under the key
        tfma.LABELS_KEY.
      """
  
      def extract_labels(  # pylint: disable=invalid-name
          batched_extracts: types.Extracts,
      ) -> types.Extracts:
          """Extract labels from extracts containing features."""
          result = copy.copy(batched_extracts)
          result[
              constants.LABELS_KEY
          ] = model_util.get_feature_values_for_model_spec_field(
              list(eval_config.model_specs),
              "label_key",
              "label_keys",
              result,
              True,
          )
          return result
  
      return extracts | "ExtractLabels" >> beam.Map(extract_labels)
  
file_path: model-analysis/tensorflow_model_analysis/extractors/labels_extractor.py
imports: import copy
  import apache_beam
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.extractors import extractor
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import model_util
label_desc: Use image node_id 2 for calling a global function with example usage: _ExtractLabels(extracts, eval_config) and returns: unknown, result