class_docstr: A config which contains the following key-value pairs related to confidence scores.
  
  Args:
      preserve_frame_confidence: Bool flag which preserves the history of per-frame confidence scores
          generated during decoding. When set to true, the Hypothesis will contain
          the non-null value for `frame_confidence` in it. Here, `frame_confidence` is a List of floats.
      preserve_token_confidence: Bool flag which preserves the history of per-token confidence scores
          generated during greedy decoding (sample / batched). When set to true, the Hypothesis will contain
          the non-null value for `token_confidence` in it. Here, `token_confidence` is a List of floats.
  
          The length of the list corresponds to the number of recognized tokens.
      preserve_word_confidence: Bool flag which preserves the history of per-word confidence scores
          generated during greedy decoding (sample / batched). When set to true, the Hypothesis will contain
          the non-null value for `word_confidence` in it. Here, `word_confidence` is a List of floats.
  
          The length of the list corresponds to the number of recognized words.
      exclude_blank: Bool flag indicating that blank token confidence scores are to be excluded
          from the `token_confidence`.
      aggregation: Which aggregation type to use for collapsing per-token confidence into per-word confidence.
          Valid options are `mean`, `min`, `max`, `prod`.
      method_cfg: A dict-like object which contains the method name and settings to compute per-frame
          confidence scores.
  
          name: The method name (str).
              Supported values:
                  - 'max_prob' for using the maximum token probability as a confidence.
                  - 'entropy' for using a normalized entropy of a log-likelihood vector.
  
          entropy_type: Which type of entropy to use (str). Used if confidence_method_cfg.name is set to `entropy`.
              Supported values:
                  - 'gibbs' for the (standard) Gibbs entropy. If the alpha (α) is provided,
                      the formula is the following: H_α = -sum_i((p^α_i)*log(p^α_i)).
                      Note that for this entropy, the alpha should comply the following inequality:
                      (log(V)+2-sqrt(log^2(V)+4))/(2*log(V)) <= α <= (1+log(V-1))/log(V-1)
                      where V is the model vocabulary size.
                  - 'tsallis' for the Tsallis entropy with the Boltzmann constant one.
                      Tsallis entropy formula is the following: H_α = 1/(α-1)*(1-sum_i(p^α_i)),
                      where α is a parameter. When α == 1, it works like the Gibbs entropy.
                      More: https://en.wikipedia.org/wiki/Tsallis_entropy
                  - 'renyi' for the Rényi entropy.
                      Rényi entropy formula is the following: H_α = 1/(1-α)*log_2(sum_i(p^α_i)),
                      where α is a parameter. When α == 1, it works like the Gibbs entropy.
                      More: https://en.wikipedia.org/wiki/R%C3%A9nyi_entropy
  
          alpha: Power scale for logsoftmax (α for entropies). Here we restrict it to be > 0.
              When the alpha equals one, scaling is not applied to 'max_prob',
              and any entropy type behaves like the Shannon entropy: H = -sum_i(p_i*log(p_i))
  
          entropy_norm: A mapping of the entropy value to the interval [0,1].
              Supported values:
                  - 'lin' for using the linear mapping.
                  - 'exp' for using exponential mapping with linear shift.
class_docstr_tok: ["A","config","which","contains","the","following","key-value","pairs","related","to","confidence","scores",".","Args",":","preserve_frame_confidence",":","Bool","flag","which","preserves","the","history","of","per-frame","confidence","scores","generated","during","decoding",".","When","set","to","true",",","the","Hypothesis","will","contain","the","non-null","value","for","`","frame_confidence","`","in","it",".","Here",",","`","frame_confidence","`","is","a","List","of","floats",".","preserve_token_confidence",":","Bool","flag","which","preserves","the","history","of","per-token","confidence","scores","generated","during","greedy","decoding","(","sample","\/","batched",")",".","When","set","to","true",",","the","Hypothesis","will","contain","the","non-null","value","for","`","token_confidence","`","in","it",".","Here",",","`","token_confidence","`","is","a","List","of","floats",".","The","length","of","the","list","corresponds","to","the","number","of","recognized","tokens",".","preserve_word_confidence",":","Bool","flag","which","preserves","the","history","of","per-word","confidence","scores","generated","during","greedy","decoding","(","sample","\/","batched",")",".","When","set","to","true",",","the","Hypothesis","will","contain","the","non-null","value","for","`","word_confidence","`","in","it",".","Here",",","`","word_confidence","`","is","a","List","of","floats",".","The","length","of","the","list","corresponds","to","the","number","of","recognized","words",".","exclude_blank",":","Bool","flag","indicating","that","blank","token","confidence","scores","are","to","be","excluded","from","the","`","token_confidence","`",".","aggregation",":","Which","aggregation","type","to","use","for","collapsing","per-token","confidence","into","per-word","confidence",".","Valid","options","are","`","mean","`",",","`","min","`",",","`","max","`",",","`","prod","`",".","method_cfg",":","A","dict-like","object","which","contains","the","method","name","and","settings","to","compute","per-frame","confidence","scores",".","name",":","The","method","name","(","str",")",".","Supported","values",":","-","'max_prob","'","for","using","the","maximum","token","probability","as","a","confidence",".","-","'entropy","'","for","using","a","normalized","entropy","of","a","log-likelihood","vector",".","entropy_type",":","Which","type","of","entropy","to","use","(","str",")",".","Used","if","confidence_method_cfg.name","is","set","to","`","entropy","`",".","Supported","values",":","-","'gibbs","'","for","the","(","standard",")","Gibbs","entropy",".","If","the","alpha","(","\u03b1",")","is","provided",",","the","formula","is","the","following",":","H_\u03b1","=","-sum_i","(","(","p^\u03b1_i",")","*","log","(","p^\u03b1_i",")",")",".","Note","that","for","this","entropy",",","the","alpha","should","comply","the","following","inequality",":","(","log","(","V",")","+2-sqrt","(","log^2","(","V",")","+4",")",")","\/","(","2","*","log","(","V",")",")","<","=","\u03b1","<","=","(","1+log","(","V-1",")",")","\/log","(","V-1",")","where","V","is","the","model","vocabulary","size",".","-","'tsallis","'","for","the","Tsallis","entropy","with","the","Boltzmann","constant","one",".","Tsallis","entropy","formula","is","the","following",":","H_\u03b1","=","1\/","(","\u03b1-1",")","*","(","1-sum_i","(","p^\u03b1_i",")",")",",","where","\u03b1","is","a","parameter",".","When","\u03b1","==","1",",","it","works","like","the","Gibbs","entropy",".","More",":","https",":","\/\/en.wikipedia.org\/wiki\/Tsallis_entropy","-","'renyi","'","for","the","R\u00e9nyi","entropy",".","R\u00e9nyi","entropy","formula","is","the","following",":","H_\u03b1","=","1\/","(","1-\u03b1",")","*","log_2","(","sum_i","(","p^\u03b1_i",")",")",",","where","\u03b1","is","a","parameter",".","When","\u03b1","==","1",",","it","works","like","the","Gibbs","entropy",".","More",":","https",":","\/\/en.wikipedia.org\/wiki\/R","%","C3","%","A9nyi_entropy","alpha",":","Power","scale","for","logsoftmax","(","\u03b1","for","entropies",")",".","Here","we","restrict","it","to","be",">","0",".","When","the","alpha","equals","one",",","scaling","is","not","applied","to","'max_prob","'",",","and","any","entropy","type","behaves","like","the","Shannon","entropy",":","H","=","-sum_i","(","p_i","*","log","(","p_i",")",")","entropy_norm",":","A","mapping","of","the","entropy","value","to","the","interval","[","0,1","]",".","Supported","values",":","-","'lin","'","for","using","the","linear","mapping",".","-","'exp","'","for","using","exponential","mapping","with","linear","shift","."]
code: def __post_init__(self):
      # OmegaConf.structured ensures that post_init check is always executed
      self.method_cfg = OmegaConf.structured(
          self.method_cfg
          if isinstance(self.method_cfg, ConfidenceMethodConfig)
          else ConfidenceMethodConfig(**self.method_cfg)
      )
      if self.aggregation not in ConfidenceConstants.AGGREGATIONS:
          raise ValueError(
              f"`aggregation` has to be one of the following: "
              f"{'`' + '`, `'.join(ConfidenceConstants.AGGREGATIONS) + '`'}. Provided: `{self.aggregation}`"
          )
  
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 ConfidenceConfig obj's underlying member method code with example usage: obj.__post_init__() without return types