code: def compute_confidence(
      hypothesis: Hypothesis, confidence_cfg: ConfidenceConfig
  ) -> float:
      """Computes confidence score of the full utterance from a given hypothesis.
  
      This is essentially a re-implementation of the built-in confidence
      computation in NeMo. The difference is that we aggregate full-utterance
      scores, while core functionality only supports word and token level
      aggregations.
  
      Args:
          hypothesis: generated hypothesis as returned from the transcribe
              method of the ASR model.
          confidence_cfg: confidence config specifying what kind of
              method/aggregation should be used.
  
      Returns:
          float: confidence score.
  
      """
      filtered_logprobs = get_filtered_logprobs(
          hypothesis, confidence_cfg.exclude_blank
      )
      vocab_size = filtered_logprobs.shape[1]
      aggr_func = get_confidence_aggregation_bank()[
          confidence_cfg.aggregation
      ]
      if confidence_cfg.method_cfg.name == "max_prob":
          conf_type = "max_prob"
          alpha = 1.0
      else:
          conf_type = f"entropy_{confidence_cfg.method_cfg.entropy_type}_{confidence_cfg.method_cfg.entropy_norm}"
          alpha = confidence_cfg.method_cfg.alpha
      conf_func = get_confidence_measure_bank()[conf_type]
  
      conf_value = (
          aggr_func(conf_func(filtered_logprobs, v=vocab_size, t=alpha))
          .cpu()
          .item()
      )
  
      return conf_value
  
imports: from dataclasses import dataclass
  from typing import Dict, List, Optional, Union
  import joblib
  import numpy
  import torch
  from omegaconf import DictConfig, open_dict
  from pytorch_lightning import Trainer
  from nemo.collections.asr.models.asr_model import ASRModel
  from nemo.collections.asr.models.hybrid_rnnt_ctc_models import EncDecHybridRNNTCTCModel
  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.audio_utils import ChannelSelectorType
  from nemo.collections.asr.parts.utils.rnnt_utils import Hypothesis
  from nemo.core.classes import ModelPT
  from nemo.utils import model_utils
label_desc: Use image node_id 2 for calling a global function with example usage: compute_confidence(hypothesis, confidence_cfg) and returns: conf_value