code: def ModelAgnosticExtractor(
      model_agnostic_config: agnostic_predict.ModelAgnosticConfig,
      desired_batch_size: Optional[int] = None,
  ) -> extractor.Extractor:
      """Creates an Extractor for ModelAgnosticEval.
  
      The extractor's PTransform creates and runs ModelAgnosticEval against every
      example yielding a copy of the Extracts input with an additional extract of
      type FeaturesPredictionsLabels keyed by tfma.FEATURES_PREDICTIONS_LABELS_KEY.
  
      Args:
        model_agnostic_config: The config to use to be able to generate Features,
          Predictions, and Labels dict. This can be done through explicit labeling
          of keys in the input tf.Example.
        desired_batch_size: Optional batch size for batching in Predict.
  
      Returns:
        Extractor for extracting features, predictions, and labels during predict.
  
      Raises:
        ValueError: Supplied ModelAgnosticConfig is invalid.
      """
      return extractor.Extractor(
          stage_name="ModelAgnosticExtractor",
          ptransform=ModelAgnosticExtract(
              model_agnostic_config=model_agnostic_config,
              desired_batch_size=desired_batch_size,
          ),
      )
  
imports: import copy
  import datetime
  from typing import Generator, List, Optional
  import apache_beam
  from apache_beam.utils import shared
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.eval_metrics_graph import eval_metrics_graph
  from tensorflow_model_analysis.extractors import extractor
  from tensorflow_model_analysis.model_agnostic_eval import model_agnostic_predict
label_desc: Use image node_id 2 for calling a global function with example usage: ModelAgnosticExtractor(model_agnostic_config, desired_batch_size) and returns: extractor