code: def compute_all_confidences(
      hypothesis: Hypothesis, tune_confidence_cfg: TuneConfidenceConfig
  ) -> Dict[ConfidenceSpec, float]:
      """Computes a set of confidence scores from a given hypothesis.
  
      Works with the output of both CTC and Transducer decoding.
  
      Args:
          hypothesis: generated hypothesis as returned from the transcribe
              method of the ASR model.
          tune_confidence_cfg: config specifying what confidence scores to
              compute.
  
      Returns:
          dict: dictionary with confidenct spec -> confidence score mapping.
      """
      conf_values = {}
  
      for exclude_blank in tune_confidence_cfg.exclude_blank:
          filtered_logprobs = get_filtered_logprobs(
              hypothesis, exclude_blank
          )
          vocab_size = filtered_logprobs.shape[1]
          for aggregation in tune_confidence_cfg.aggregation:
              aggr_func = get_confidence_aggregation_bank()[aggregation]
              for conf_type in tune_confidence_cfg.confidence_type:
                  conf_func = get_confidence_measure_bank()[conf_type]
                  if (
                      conf_type == "max_prob"
                  ):  # skipping alpha in this case
                      conf_value = (
                          aggr_func(
                              conf_func(
                                  filtered_logprobs, v=vocab_size, t=1.0
                              )
                          )
                          .cpu()
                          .item()
                      )
                      conf_values[
                          ConfidenceSpec(
                              exclude_blank, aggregation, conf_type, 1.0
                          )
                      ] = conf_value
                  else:
                      for alpha in tune_confidence_cfg.alpha:
                          conf_value = (
                              aggr_func(
                                  conf_func(
                                      filtered_logprobs,
                                      v=vocab_size,
                                      t=alpha,
                                  )
                              )
                              .cpu()
                              .item()
                          )
                          conf_values[
                              ConfidenceSpec(
                                  exclude_blank,
                                  aggregation,
                                  conf_type,
                                  alpha,
                              )
                          ] = conf_value
  
      return conf_values
  
imports: import atexit
  import logging
  import os
  import random
  import sys
  import tempfile
  from copy import deepcopy
  from dataclasses import dataclass, field
  from pathlib import Path
  from typing import Dict, List, Optional, Tuple
  import joblib
  import numpy
  import pytorch_lightning
  from omegaconf import MISSING, DictConfig, OmegaConf
  from sklearn.linear_model import LogisticRegression
  from sklearn.metrics import confusion_matrix
  from sklearn.pipeline import Pipeline, make_pipeline
  from sklearn.preprocessing import StandardScaler
  from tqdm import tqdm
  from nemo.collections.asr.models.confidence_ensemble import ConfidenceEnsembleModel, ConfidenceSpec, compute_confidence, get_filtered_logprobs
  from nemo.collections.asr.parts.utils.asr_confidence_utils import ConfidenceConfig, ConfidenceMethodConfig, get_confidence_aggregation_bank, get_confidence_measure_bank
  from nemo.collections.asr.parts.utils.rnnt_utils import Hypothesis
  from nemo.core.config import hydra_runner
label_desc: Use image node_id 5 for calling a global function with example usage: compute_all_confidences(hypothesis, tune_confidence_cfg) and returns: conf_values