code: def _ExtractExampleWeights(
      extracts: beam.pvalue.PCollection,
      eval_config: config_pb2.EvalConfig,
  ) -> beam.pvalue.PCollection:
      """Extracts example weights from features extracts.
  
      Args:
        extracts: PCollection containing features under tfma.FEATURES_KEY.
        eval_config: Eval config.
  
      Returns:
        PCollection of extracts with additional example weights added under the key
        tfma.EXAMPLE_WEIGHTS_KEY.
      """
  
      def extract_example_weights(  # pylint: disable=invalid-name
          batched_extracts: types.Extracts,
      ) -> types.Extracts:
          """Extract example weights from extracts containing features."""
          result = copy.copy(batched_extracts)
          example_weights = (
              model_util.get_feature_values_for_model_spec_field(
                  list(eval_config.model_specs),
                  "example_weight_key",
                  "example_weight_keys",
                  result,
              )
          )
          if example_weights is not None:
              result[constants.EXAMPLE_WEIGHTS_KEY] = example_weights
          return result
  
      return extracts | "ExtractExampleWeights" >> beam.Map(
          extract_example_weights
      )
  
file_path: model-analysis/tensorflow_model_analysis/extractors/example_weights_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: _ExtractExampleWeights(extracts, eval_config) and returns: unknown, result