code: def get_slicing_metrics(
      results: List[Tuple[slicer.SliceKeyType, Dict[str, Any]]],
      slicing_column: Optional[str] = None,
      slicing_spec: Optional[slicer.SingleSliceSpec] = None,
  ) -> List[Dict[str, Union[Dict[str, Any], str]]]:
      """Util function that extracts slicing metrics from the results.
  
      If neither slicing_column nor slicing_spec is provided, get Overall. If
      slicing_column is set, use it to filter metrics from results. Otherwise, use
      slicing_spec for filtering.
  
      Args:
        results: A list of records. Each record is a tuple of (slice_name,
          {output_name: {sub_key: {metric_name, metric_value}}}).
        slicing_column: The column to filter the resuslts with.
        slicing_spec: The slicer.SingleSliceSpec to filter the resutls with.
  
      Returns:
        A list of {slice, metrics}
  
      Raises:
        ValueError: The provided slicing_column does not exist in results or more
        than one set of overall result is found.
      """
  
      if slicing_column:
          data = find_all_slices(
              results, slicer.SingleSliceSpec(columns=[slicing_column])
          )
      elif not slicing_spec:
          data = find_all_slices(results, slicer.SingleSliceSpec())
      else:
          data = find_all_slices(results, slicing_spec)
  
      slice_count = len(data)
      if not slice_count:
          if not slicing_spec:
              if not slicing_column:
                  slicing_column = slicer.OVERALL_SLICE_NAME
              raise ValueError(
                  "No slices found for %s" % slicing_column
              )
          else:
              raise ValueError("No slices found for %s" % slicing_spec)
      elif not slicing_column and not slicing_spec and slice_count > 1:
          raise ValueError(
              "More than one slice found for %s"
              % slicer.OVERALL_SLICE_NAME
          )
      else:
          return data
  
imports: import json
  import os
  from typing import Any, Dict, List, Optional, Tuple, Union
  from absl import logging
  from tensorflow_model_analysis.metrics import example_count
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import weighted_example_count
  from tensorflow_model_analysis.post_export_metrics import metric_keys
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
  from tensorflow_model_analysis.slicer import slicer_lib
  from tensorflow_model_analysis.view import view_types
  from google.protobuf import json_format
label_desc: Use image node_id 1 for calling a global function with example usage: get_slicing_metrics(results, slicing_column, slicing_spec) and returns: data