code: def _ParseExample(
      extracts: types.Extracts, eval_config: config_pb2.EvalConfig
  ):
      """Parses serialized tf.train.Example to create additional extracts.
  
      Args:
        extracts: PCollection containing serialized examples under tfma.INPUT_KEY.
        eval_config: Eval config.
  
      Returns:
        Extracts with additional keys added for features, labels, and example
        weights.
      """
  
      features = example_coder.ExampleToNumpyDict(
          extracts[constants.INPUT_KEY]
      )
      extracts = copy.copy(extracts)
  
      def add_to_extracts(  # pylint: disable=invalid-name
          key: str, model_name: str, feature_values: Any
      ):
          """Adds features_values to extracts and feature_keys to keys_to_pop."""
          # Only key by model name if multiple models.
          if len(eval_config.model_specs) > 1:
              if key not in extracts:
                  extracts[key] = {}
              extracts[key][model_name] = feature_values
          else:
              extracts[key] = feature_values
  
      for spec in eval_config.model_specs:
          if spec.label_key or spec.label_keys:
              _, values = _keys_and_values(
                  spec.label_key or dict(spec.label_keys), features
              )
              add_to_extracts(constants.LABELS_KEY, spec.name, values)
          if spec.example_weight_key or spec.example_weight_keys:
              _, values = _keys_and_values(
                  spec.example_weight_key
                  or dict(spec.example_weight_keys),
                  features,
              )
              add_to_extracts(
                  constants.EXAMPLE_WEIGHTS_KEY, spec.name, values
              )
          if spec.prediction_key or spec.prediction_keys:
              _, values = _keys_and_values(
                  spec.prediction_key or dict(spec.prediction_keys),
                  features,
              )
              add_to_extracts(
                  constants.PREDICTIONS_KEY, spec.name, values
              )
      extracts[constants.FEATURES_KEY] = features
      return extracts
  
file_path: model-analysis/tensorflow_model_analysis/extractors/legacy_input_extractor.py
imports: import copy
  from typing import Any, Dict, List, Optional, Tuple, Union
  import apache_beam
  import numpy
  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 tfx_bsl.coders import example_coder
label_desc: Use image node_id 3 for calling a global function with example usage: _ParseExample(extracts, eval_config) and returns: extracts