class_docstr: Confidence Mixin class.
  
  It is responsible for confidence estimation method initialization and high-level confidence score calculation.
class_docstr_tok: ["Confidence","Mixin","class",".","It","is","responsible","for","confidence","estimation","method","initialization","and","high-level","confidence","score","calculation","."]
docstr: Initialize confidence-related fields and confidence aggregation function from config.
          
docstr_tok: ["Initialize","confidence-related","fields","and","confidence","aggregation","function","from","config","."]
code: def _init_confidence(
      self, confidence_cfg: Optional[DictConfig] = None
  ):
      """Initialize confidence-related fields and confidence aggregation function from config."""
      # OmegaConf.structured ensures that post_init check is always executed
      confidence_cfg = OmegaConf.structured(
          ConfidenceConfig()
          if confidence_cfg is None
          else ConfidenceConfig(**confidence_cfg)
      )
      self.confidence_method_cfg = confidence_cfg.method_cfg
  
      # extract the config
      self.preserve_word_confidence = confidence_cfg.get(
          "preserve_word_confidence", False
      )
      # set preserve_frame_confidence and preserve_token_confidence to True
      # if preserve_word_confidence is True
      self.preserve_token_confidence = (
          confidence_cfg.get("preserve_token_confidence", False)
          | self.preserve_word_confidence
      )
      # set preserve_frame_confidence to True if preserve_token_confidence is True
      self.preserve_frame_confidence = (
          confidence_cfg.get("preserve_frame_confidence", False)
          | self.preserve_token_confidence
      )
      self.exclude_blank_from_confidence = confidence_cfg.get(
          "exclude_blank", True
      )
      self.word_confidence_aggregation = confidence_cfg.get(
          "aggregation", "min"
      )
  
      # define aggregation functions
      self.confidence_aggregation_bank = (
          get_confidence_aggregation_bank()
      )
      self._aggregate_confidence = self.confidence_aggregation_bank[
          self.word_confidence_aggregation
      ]
  
      # Update preserve frame confidence
      if self.preserve_frame_confidence is False:
          if self.cfg.strategy in ["greedy", "greedy_batch"]:
              self.preserve_frame_confidence = self.cfg.greedy.get(
                  "preserve_frame_confidence", False
              )
              # OmegaConf.structured ensures that post_init check is always executed
              confidence_method_cfg = OmegaConf.structured(
                  self.cfg.greedy
              ).get("confidence_method_cfg", None)
              self.confidence_method_cfg = (
                  OmegaConf.structured(ConfidenceMethodConfig())
                  if confidence_method_cfg is None
                  else OmegaConf.structured(
                      ConfidenceMethodConfig(**confidence_method_cfg)
                  )
              )
  
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 ConfidenceMixin obj's underlying member method code with example usage: obj._init_confidence(confidence_cfg) without return types