class_docstr: The result of a single model analysis run.
  
  Attributes:
    slicing_metrics: a list of `tfma.SlicedMetrics`, containing metric values
      for each slice.
    plots: List of slice-plot pairs.
    attributions: List of SlicedAttributions containing attribution values for
      each slice.
    config: The config containing slicing and metrics specification.
    data_location: Optional location for data used with config.
    file_format: Optional format for data used with config.
    model_location: Optional location(s) for model(s) used with config.
docstr: Get metric names and values for a slice.
  
  Args:
    slice_name: A tuple of the form (column, value), indicating which slice to
      get metrics from. Optional; if excluded, return overall metrics.
    output_name: The name of the output. Optional, only used for multi-output
      models.
    class_id: Used with multi-class metrics to identify a specific class ID.
    k: Used with multi-class metrics to identify the kth predicted value.
    top_k: Used with multi-class and ranking metrics to identify top-k
      predicted values.
  
  Returns:
    Dictionary containing metric names and values for the specified slice.
docstr_tok: ["Get","metric","names","and","values","for","a","slice",".","Args",":","slice_name",":","A","tuple","of","the","form","(","column",",","value",")",",","indicating","which","slice","to","get","metrics","from",".","Optional",";","if","excluded",",","return","overall","metrics",".","output_name",":","The","name","of","the","output",".","Optional",",","only","used","for","multi-output","models",".","class_id",":","Used","with","multi-class","metrics","to","identify","a","specific","class","ID",".","k",":","Used","with","multi-class","metrics","to","identify","the","kth","predicted","value",".","top_k",":","Used","with","multi-class","and","ranking","metrics","to","identify","top-k","predicted","values",".","Returns",":","Dictionary","containing","metric","names","and","values","for","the","specified","slice","."]
code: def get_metrics_for_slice(
      self,
      slice_name: slicer.SliceKeyType = (),
      output_name: str = "",
      class_id: Optional[int] = None,
      k: Optional[int] = None,
      top_k: Optional[int] = None,
  ) -> Union[MetricsByTextKey, None]:
      """Get metric names and values for a slice.
  
      Args:
        slice_name: A tuple of the form (column, value), indicating which slice to
          get metrics from. Optional; if excluded, return overall metrics.
        output_name: The name of the output. Optional, only used for multi-output
          models.
        class_id: Used with multi-class metrics to identify a specific class ID.
        k: Used with multi-class metrics to identify the kth predicted value.
        top_k: Used with multi-class and ranking metrics to identify top-k
          predicted values.
  
      Returns:
        Dictionary containing metric names and values for the specified slice.
      """
      if all(v is None for v in [class_id, k, top_k]):
          sub_key = ""
      else:
          sub_key = str(metric_types.SubKey(class_id, k, top_k))
  
      def equals_slice_name(slice_key):
          if not slice_key:
              return not slice_name
          else:
              return slice_key == slice_name
  
      for slicing_metric in self.slicing_metrics:
          slice_key = slicing_metric[0]
          slice_val = slicing_metric[1]
          if equals_slice_name(slice_key):
              return slice_val[output_name][sub_key]
  
      # if slice could not be found, return None
      return None
  
imports: import copy
  from typing import Any, Dict, List, Sequence, NamedTuple, Optional, Union
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.metrics import metric_types
  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
label_desc: Use image node_id 1 for calling the EvalResult obj's underlying member method code with example usage: obj.get_metrics_for_slice(slice_name, output_name, class_id, k, top_k) and returns: None, unknown, unknown, slice_val