code: def _multi_class_confusion_matrix_at_thresholds(
      thresholds: Optional[List[float]] = None,
      name: str = MULTI_CLASS_CONFUSION_MATRIX_AT_THRESHOLDS_NAME,
      eval_config: Optional[config_pb2.EvalConfig] = None,
      model_name: str = "",
      output_name: str = "",
      example_weighted: bool = False,
  ) -> metric_types.MetricComputations:
      """Returns computations for multi-class confusion matrix at thresholds."""
      if not thresholds:
          thresholds = [0.5]
  
      key = metric_types.MetricKey(
          name=name,
          model_name=model_name,
          output_name=output_name,
          example_weighted=example_weighted,
      )
  
      # Make sure matrices are calculated.
      matrices_computations = multi_class_confusion_matrices(
          thresholds=thresholds,
          eval_config=eval_config,
          model_name=model_name,
          output_name=output_name,
          example_weighted=example_weighted,
      )
      matrices_key = matrices_computations[-1].keys[-1]
  
      def result(
          metrics: Dict[
              metric_types.MetricKey,
              metrics_for_slice_pb2.MultiClassConfusionMatrixAtThresholds,
          ]
      ) -> Dict[
          metric_types.MetricKey,
          metrics_for_slice_pb2.MultiClassConfusionMatrixAtThresholds,
      ]:
          return {key: metrics[matrices_key]}
  
      derived_computation = metric_types.DerivedMetricComputation(
          keys=[key], result=result
      )
      computations = matrices_computations
      computations.append(derived_computation)
      return computations
  
imports: from typing import Any, Callable, Dict, Iterable, Iterator, List, NamedTuple, Optional, Tuple
  import apache_beam
  import numpy
  from tensorflow_model_analysis.api import types
  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.proto import metrics_for_slice_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: _multi_class_confusion_matrix_at_thresholds(thresholds, name, eval_config, model_name, output_name, example_weighted) and returns: computations, dict