class_docstr: Confidence Method Mixin class.
  
  It initializes per-frame confidence method.
class_docstr_tok: ["Confidence","Method","Mixin","class",".","It","initializes","per-frame","confidence","method","."]
docstr: Initialize per-frame confidence method from config.
          
docstr_tok: ["Initialize","per-frame","confidence","method","from","config","."]
code: def _init_confidence_method(
      self, confidence_method_cfg: Optional[DictConfig] = None
  ):
      """Initialize per-frame confidence method from config."""
      # OmegaConf.structured ensures that post_init check is always executed
      confidence_method_cfg = OmegaConf.structured(
          ConfidenceMethodConfig()
          if confidence_method_cfg is None
          else ConfidenceMethodConfig(**confidence_method_cfg)
      )
  
      # set confidence calculation method
      # we suppose that self.blank_id == len(vocabulary)
      self.num_tokens = (
          self.blank_id
          if hasattr(self, "blank_id")
          else self._blank_index
      ) + 1
      self.alpha = confidence_method_cfg.alpha
  
      # init confidence measure bank
      self.confidence_measure_bank = get_confidence_measure_bank()
  
      measure = None
      # construct measure_name
      measure_name = ""
      if confidence_method_cfg.name == "max_prob":
          measure_name = "max_prob"
      elif confidence_method_cfg.name == "entropy":
          measure_name = "_".join(
              [
                  confidence_method_cfg.name,
                  confidence_method_cfg.entropy_type,
                  confidence_method_cfg.entropy_norm,
              ]
          )
      else:
          raise ValueError(
              f"Unsupported `confidence_method_cfg.name`: `{confidence_method_cfg.name}`"
          )
      if measure_name not in self.confidence_measure_bank:
          raise ValueError(
              f"Unsupported measure setup: `{measure_name}`"
          )
      measure = partial(
          self.confidence_measure_bank[measure_name],
          v=self.num_tokens,
          t=self.alpha,
      )
      self._get_confidence = lambda x: measure(
          torch.nan_to_num(x)
      ).tolist()
  
imports: import math
  from abc import ABC, abstractmethod
  from dataclasses import dataclass, field
  from functools import partial
  from typing import List, Optional
  import torch
  from omegaconf import DictConfig, OmegaConf
  from nemo.collections.asr.parts.utils.rnnt_utils import Hypothesis
  from nemo.utils import logging
label_desc: Use image node_id 1 for calling the ConfidenceMethodMixin obj's underlying member method code with example usage: obj._init_confidence_method(confidence_method_cfg) without return types