code: def _EvaluateMetricsPlotsAndValidations(  # pylint: disable=invalid-name
      extracts: beam.pvalue.PCollection,
      eval_config: config_pb2.EvalConfig,
      eval_shared_models: Optional[
          Dict[str, types.EvalSharedModel]
      ] = None,
      metrics_key: str = constants.METRICS_KEY,
      plots_key: str = constants.PLOTS_KEY,
      attributions_key: str = constants.ATTRIBUTIONS_KEY,
      validations_key: str = constants.VALIDATIONS_KEY,
      schema: Optional[schema_pb2.Schema] = None,
      random_seed_for_testing: Optional[int] = None,
  ) -> evaluator.Evaluation:
      """Evaluates metrics, plots, and validations.
  
      Args:
        extracts: PCollection of Extracts. The extracts must contain a list of
          slices of type SliceKeyType keyed by tfma.SLICE_KEY_TYPES_KEY as well as
          any extracts required by the metric implementations (typically this will
          include labels keyed by tfma.LABELS_KEY, predictions keyed by
          tfma.PREDICTIONS_KEY, and example weights keyed by
          tfma.EXAMPLE_WEIGHTS_KEY). Usually these will be added by calling the
          default_extractors function.
        eval_config: Eval config.
        eval_shared_models: Optional dict of shared models keyed by model name. Only
          required if there are metrics to be computed in-graph using the model.
        metrics_key: Name to use for metrics key in Evaluation output.
        plots_key: Name to use for plots key in Evaluation output.
        attributions_key: Name to use for attributions key in Evaluation output.
        validations_key: Name to use for validation key in Evaluation output.
        schema: A schema to use for customizing metrics and plots.
        random_seed_for_testing: Seed to use for unit testing.
  
      Returns:
        Evaluation containing dict of PCollections of (slice_key, results_dict)
        tuples where the dict is keyed by either the metrics_key (e.g. 'metrics'),
        plots_key (e.g. 'plots'), attributions_key (e.g. 'attributions'), or
        validation_key (e.g. 'validations') depending on what the results_dict
        contains.
      """
      # Separate metrics based on query_key (which may be None).
      metrics_specs_by_query_key = {}
      for spec in eval_config.metrics_specs:
          if spec.query_key not in metrics_specs_by_query_key:
              metrics_specs_by_query_key[spec.query_key] = []
          metrics_specs_by_query_key[spec.query_key].append(spec)
  
      # If there are no metrics specs then add an empty one (this is required for
      # cases where only the default metrics from the model are used).
      if not metrics_specs_by_query_key:
          metrics_specs_by_query_key[""] = [config_pb2.MetricsSpec()]
  
      # pylint: disable=no-value-for-parameter
  
      evaluations = {}
      for (
          query_key,
          metrics_specs,
      ) in metrics_specs_by_query_key.items():
          query_key_text = query_key if query_key else ""
          if query_key:
              extracts_for_evaluation = (
                  extracts
                  | "GroupByQueryKey({})".format(query_key_text)
                  >> _GroupByQueryKey(query_key)
              )
              include_default_metrics = False
          else:
              extracts_for_evaluation = extracts
              include_default_metrics = eval_config and (
                  not eval_config.options.HasField(
                      "include_default_metrics"
                  )
                  or eval_config.options.include_default_metrics.value
              )
          evaluation = (
              extracts_for_evaluation
              | "ComputeMetricsAndPlots({})".format(query_key_text)
              >> _ComputeMetricsAndPlots(
                  eval_config=eval_config,
                  metrics_specs=metrics_specs,
                  eval_shared_models=(
                      eval_shared_models
                      if include_default_metrics
                      else None
                  ),
                  metrics_key=metrics_key,
                  plots_key=plots_key,
                  attributions_key=attributions_key,
                  schema=schema,
                  random_seed_for_testing=random_seed_for_testing,
              )
          )
  
          for k, v in evaluation.items():
              if k not in evaluations:
                  evaluations[k] = []
              evaluations[k].append(v)
      evaluation_results = evaluator.combine_dict_based_evaluations(
          evaluations
      )
  
      validations = evaluation_results[
          metrics_key
      ] | "ValidateMetrics" >> beam.Map(
          metrics_validator.validate_metrics, eval_config
      )
      evaluation_results[validations_key] = validations
      return evaluation_results
  
imports: import copy
  import datetime
  import itertools
  import numbers
  from typing import Any, Dict, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Type, TypeVar, Union
  import apache_beam
  import numpy
  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 eval_saved_model_util
  from tensorflow_model_analysis.evaluators import evaluator
  from tensorflow_model_analysis.evaluators import jackknife
  from tensorflow_model_analysis.evaluators import keras_util
  from tensorflow_model_analysis.evaluators import metrics_validator
  from tensorflow_model_analysis.evaluators import poisson_bootstrap
  from tensorflow_model_analysis.extractors import slice_key_extractor
  from tensorflow_model_analysis.metrics import metric_specs
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.slicer import slicer_lib
  from tensorflow_model_analysis.utils import model_util
  from tensorflow_model_analysis.utils import util
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 13 for calling a global function with example usage: _EvaluateMetricsPlotsAndValidations(extracts, eval_config, eval_shared_models, metrics_key, plots_key, attributions_key, validations_key, schema, random_seed_for_testing) and returns: evaluation_results