code: def MetricsAndPlotsEvaluator(  # pylint: disable=invalid-name
      eval_shared_model: types.EvalSharedModel,
      desired_batch_size: Optional[int] = None,
      metrics_key: str = constants.METRICS_KEY,
      plots_key: str = constants.PLOTS_KEY,
      run_after: str = slice_key_extractor.SLICE_KEY_EXTRACTOR_STAGE_NAME,
      compute_confidence_intervals: Optional[bool] = False,
      min_slice_size: int = 1,
      serialize=False,
      random_seed_for_testing: Optional[int] = None,
  ) -> evaluator.Evaluator:
      """Creates an Evaluator for evaluating metrics and plots.
  
      Args:
        eval_shared_model: Shared model parameters for EvalSavedModel.
        desired_batch_size: Optional batch size for batching in Aggregate.
        metrics_key: Name to use for metrics key in Evaluation output.
        plots_key: Name to use for plots key in Evaluation output.
        run_after: Extractor to run after (None means before any extractors).
        compute_confidence_intervals: Whether or not to compute confidence
          intervals.
        min_slice_size: If the number of examples in a specific slice is less
          than min_slice_size, then an error will be returned for that slice.
          This will be useful to ensure privacy by not displaying the aggregated
          data for smaller number of examples.
        serialize: If true, serialize the metrics to protos as part of the
          evaluation as well.
        random_seed_for_testing: Provide for deterministic tests only.
  
      Returns:
        Evaluator for evaluating metrics and plots. The output will be stored under
        'metrics' and 'plots' keys.
      """
      # pylint: disable=no-value-for-parameter
      return evaluator.Evaluator(
          stage_name="EvaluateMetricsAndPlots",
          run_after=run_after,
          ptransform=_EvaluateMetricsAndPlots(
              eval_shared_model=eval_shared_model,
              desired_batch_size=desired_batch_size,
              metrics_key=metrics_key,
              plots_key=plots_key,
              compute_confidence_intervals=compute_confidence_intervals,
              min_slice_size=min_slice_size,
              serialize=serialize,
              random_seed_for_testing=random_seed_for_testing,
          ),
      )
  
file_path: model-analysis/tensorflow_model_analysis/evaluators/legacy_metrics_and_plots_evaluator.py
imports: from typing import Any, Dict, Optional, Tuple
  import apache_beam
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.evaluators import counter_util
  from tensorflow_model_analysis.evaluators import evaluator
  from tensorflow_model_analysis.evaluators import legacy_aggregate
  from tensorflow_model_analysis.evaluators import legacy_poisson_bootstrap
  from tensorflow_model_analysis.extractors import extractor
  from tensorflow_model_analysis.extractors import slice_key_extractor
  from tensorflow_model_analysis.post_export_metrics import metric_keys
  from tensorflow_model_analysis.slicer import slicer_lib
  from tensorflow_model_analysis.writers import metrics_plots_and_validations_writer
label_desc: Use image node_id 1 for calling a global function with example usage: MetricsAndPlotsEvaluator(eval_shared_model, desired_batch_size, metrics_key, plots_key, run_after, compute_confidence_intervals, min_slice_size, serialize, random_seed_for_testing) and returns: evaluator