code: def ComputePerSliceMetrics(  # pylint: disable=invalid-name
      slice_result: beam.pvalue.PCollection,
      eval_shared_model: types.EvalSharedModel,
      desired_batch_size: Optional[int] = None,
      compute_with_sampling: Optional[bool] = False,
      random_seed_for_testing: Optional[int] = None,
  ) -> beam.pvalue.PCollection:
      """PTransform for computing, aggregating and combining metrics.
  
      Args:
        slice_result: Incoming PCollection consisting of slice key and extracts.
        eval_shared_model: Shared model parameters for EvalSavedModel.
        desired_batch_size: Optional batch size for batching in Aggregate.
        compute_with_sampling: True to compute with sampling.
        random_seed_for_testing: Seed to use for unit testing.
  
      Returns:
        PCollection of (slice key, dict of metrics).
      """
      return (
          slice_result
          | "CombinePerSlice"
          >> beam.CombinePerKey(
              _AggregateCombineFn(
                  eval_shared_model=eval_shared_model,
                  desired_batch_size=desired_batch_size,
                  compute_with_sampling=compute_with_sampling,
                  seed_for_testing=random_seed_for_testing,
              )
          )
          | "InterpretOutput"
          >> beam.ParDo(
              _ExtractOutputDoFn(eval_shared_model=eval_shared_model)
          )
      )
  
imports: from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple
  import apache_beam
  import numpy
  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.slicer import slicer_lib
  from tensorflow_model_analysis.utils import model_util
  from tensorflow_model_analysis.utils import size_estimator
label_desc: Use image node_id 1 for calling a global function with example usage: ComputePerSliceMetrics(slice_result, eval_shared_model, desired_batch_size, compute_with_sampling, random_seed_for_testing) and returns: unknown