class_docstr: Used for performing RNN-T auto-regressive decoding of the Decoder+Joint network given the encoder state.
  
  Args:
      decoding_cfg: A dict-like object which contains the following key-value pairs.
          strategy: str value which represents the type of decoding that can occur.
              Possible values are :
              -   greedy, greedy_batch (for greedy decoding).
              -   beam, tsd, alsd (for beam search decoding).
  
          compute_hypothesis_token_set: A bool flag, which determines whether to compute a list of decoded
              tokens as well as the decoded string. Default is False in order to avoid double decoding
              unless required.
  
          preserve_alignments: Bool flag which preserves the history of logprobs generated during
              decoding (sample / batched). When set to true, the Hypothesis will contain
              the non-null value for `alignments` in it. Here, `alignments` is a List of List of
              Tuple(Tensor (of length V + 1), Tensor(scalar, label after argmax)).
  
              In order to obtain this hypothesis, please utilize `rnnt_decoder_predictions_tensor` function
              with the `return_hypotheses` flag set to True.
  
              The length of the list corresponds to the Acoustic Length (T).
              Each value in the list (Ti) is a torch.Tensor (U), representing 1 or more targets from a vocabulary.
              U is the number of target tokens for the current timestep Ti.
  
          compute_timestamps: A bool flag, which determines whether to compute the character/subword, or
              word based timestamp mapping the output log-probabilities to discrete intervals of timestamps.
              The timestamps will be available in the returned Hypothesis.timestep as a dictionary.
  
          compute_langs: a bool flag, which allows to compute language id (LID) information per token,
              word, and the entire sample (most likely language id). The LIDS will be available
              in the returned Hypothesis object as a dictionary
  
          rnnt_timestamp_type: A str value, which represents the types of timestamps that should be calculated.
              Can take the following values - "char" for character/subword time stamps, "word" for word level
              time stamps and "all" (default), for both character level and word level time stamps.
  
          word_seperator: Str token representing the seperator between words.
  
          preserve_frame_confidence: Bool flag which preserves the history of per-frame confidence scores
              generated during decoding (sample / batched). When set to true, the Hypothesis will contain
              the non-null value for `frame_confidence` in it. Here, `alignments` is a List of List of ints.
  
          confidence_cfg: A dict-like object which contains the following key-value pairs related to confidence
              scores. In order to obtain hypotheses with confidence scores, please utilize
              `rnnt_decoder_predictions_tensor` function with the `preserve_frame_confidence` flag set to True.
  
              preserve_frame_confidence: Bool flag which preserves the history of per-frame confidence scores
                  generated during decoding (sample / batched). When set to true, the Hypothesis will contain
                  the non-null value for `frame_confidence` in it. Here, `alignments` is a List of List of floats.
  
                  The length of the list corresponds to the Acoustic Length (T).
                  Each value in the list (Ti) is a torch.Tensor (U), representing 1 or more confidence scores.
                  U is the number of target tokens for the current timestep Ti.
              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.
  
          The config may further contain the following sub-dictionaries:
          "greedy":
              max_symbols: int, describing the maximum number of target tokens to decode per
                  timestep during greedy decoding. Setting to larger values allows longer sentences
                  to be decoded, at the cost of increased execution time.
  
              preserve_frame_confidence: Same as above, overrides above value.
  
              confidence_method_cfg: Same as above, overrides confidence_cfg.method_cfg.
  
          "beam":
              beam_size: int, defining the beam size for beam search. Must be >= 1.
                  If beam_size == 1, will perform cached greedy search. This might be slightly different
                  results compared to the greedy search above.
  
              score_norm: optional bool, whether to normalize the returned beam score in the hypotheses.
                  Set to True by default.
  
              return_best_hypothesis: optional bool, whether to return just the best hypothesis or all of the
                  hypotheses after beam search has concluded.
  
              tsd_max_sym_exp: optional int, determines number of symmetric expansions of the target symbols
                  per timestep of the acoustic model. Larger values will allow longer sentences to be decoded,
                  at increased cost to execution time.
  
              alsd_max_target_len: optional int or float, determines the potential maximum target sequence length.
                  If an integer is provided, it can decode sequences of that particular maximum length.
                  If a float is provided, it can decode sequences of int(alsd_max_target_len * seq_len),
                  where seq_len is the length of the acoustic model output (T).
  
                  NOTE:
                      If a float is provided, it can be greater than 1!
                      By default, a float of 2.0 is used so that a target sequence can be at most twice
                      as long as the acoustic model output length T.
  
              maes_num_steps: Number of adaptive steps to take. From the paper, 2 steps is generally sufficient,
                  and can be reduced to 1 to improve decoding speed while sacrificing some accuracy. int > 0.
  
              maes_prefix_alpha: Maximum prefix length in prefix search. Must be an integer, and is advised to keep this as 1
                  in order to reduce expensive beam search cost later. int >= 0.
  
              maes_expansion_beta: Maximum number of prefix expansions allowed, in addition to the beam size.
                  Effectively, the number of hypothesis = beam_size + maes_expansion_beta. Must be an int >= 0,
                  and affects the speed of inference since large values will perform large beam search in the next step.
  
              maes_expansion_gamma: Float pruning threshold used in the prune-by-value step when computing the expansions.
                  The default (2.3) is selected from the paper. It performs a comparison (max_log_prob - gamma <= log_prob[v])
                  where v is all vocabulary indices in the Vocab set and max_log_prob is the "most" likely token to be
                  predicted. Gamma therefore provides a margin of additional tokens which can be potential candidates for
                  expansion apart from the "most likely" candidate.
                  Lower values will reduce the number of expansions (by increasing pruning-by-value, thereby improving speed
                  but hurting accuracy). Higher values will increase the number of expansions (by reducing pruning-by-value,
                  thereby reducing speed but potentially improving accuracy). This is a hyper parameter to be experimentally
                  tuned on a validation set.
  
              softmax_temperature: Scales the logits of the joint prior to computing log_softmax.
  
      decoder: The Decoder/Prediction network module.
      joint: The Joint network module.
      tokenizer: The tokenizer which will be used for decoding.
class_docstr_tok: ["Used","for","performing","RNN-T","auto-regressive","decoding","of","the","Decoder+Joint","network","given","the","encoder","state",".","Args",":","decoding_cfg",":","A","dict-like","object","which","contains","the","following","key-value","pairs",".","strategy",":","str","value","which","represents","the","type","of","decoding","that","can","occur",".","Possible","values","are",":","-","greedy",",","greedy_batch","(","for","greedy","decoding",")",".","-","beam",",","tsd",",","alsd","(","for","beam","search","decoding",")",".","compute_hypothesis_token_set",":","A","bool","flag",",","which","determines","whether","to","compute","a","list","of","decoded","tokens","as","well","as","the","decoded","string",".","Default","is","False","in","order","to","avoid","double","decoding","unless","required",".","preserve_alignments",":","Bool","flag","which","preserves","the","history","of","logprobs","generated","during","decoding","(","sample","\/","batched",")",".","When","set","to","true",",","the","Hypothesis","will","contain","the","non-null","value","for","`","alignments","`","in","it",".","Here",",","`","alignments","`","is","a","List","of","List","of","Tuple","(","Tensor","(","of","length","V","+","1",")",",","Tensor","(","scalar",",","label","after","argmax",")",")",".","In","order","to","obtain","this","hypothesis",",","please","utilize","`","rnnt_decoder_predictions_tensor","`","function","with","the","`","return_hypotheses","`","flag","set","to","True",".","The","length","of","the","list","corresponds","to","the","Acoustic","Length","(","T",")",".","Each","value","in","the","list","(","Ti",")","is","a","torch.Tensor","(","U",")",",","representing","1","or","more","targets","from","a","vocabulary",".","U","is","the","number","of","target","tokens","for","the","current","timestep","Ti",".","compute_timestamps",":","A","bool","flag",",","which","determines","whether","to","compute","the","character\/subword",",","or","word","based","timestamp","mapping","the","output","log-probabilities","to","discrete","intervals","of","timestamps",".","The","timestamps","will","be","available","in","the","returned","Hypothesis.timestep","as","a","dictionary",".","compute_langs",":","a","bool","flag",",","which","allows","to","compute","language","id","(","LID",")","information","per","token",",","word",",","and","the","entire","sample","(","most","likely","language","id",")",".","The","LIDS","will","be","available","in","the","returned","Hypothesis","object","as","a","dictionary","rnnt_timestamp_type",":","A","str","value",",","which","represents","the","types","of","timestamps","that","should","be","calculated",".","Can","take","the","following","values","-","``","char","''","for","character\/subword","time","stamps",",","``","word","''","for","word","level","time","stamps","and","``","all","''","(","default",")",",","for","both","character","level","and","word","level","time","stamps",".","word_seperator",":","Str","token","representing","the","seperator","between","words",".","preserve_frame_confidence",":","Bool","flag","which","preserves","the","history","of","per-frame","confidence","scores","generated","during","decoding","(","sample","\/","batched",")",".","When","set","to","true",",","the","Hypothesis","will","contain","the","non-null","value","for","`","frame_confidence","`","in","it",".","Here",",","`","alignments","`","is","a","List","of","List","of","ints",".","confidence_cfg",":","A","dict-like","object","which","contains","the","following","key-value","pairs","related","to","confidence","scores",".","In","order","to","obtain","hypotheses","with","confidence","scores",",","please","utilize","`","rnnt_decoder_predictions_tensor","`","function","with","the","`","preserve_frame_confidence","`","flag","set","to","True",".","preserve_frame_confidence",":","Bool","flag","which","preserves","the","history","of","per-frame","confidence","scores","generated","during","decoding","(","sample","\/","batched",")",".","When","set","to","true",",","the","Hypothesis","will","contain","the","non-null","value","for","`","frame_confidence","`","in","it",".","Here",",","`","alignments","`","is","a","List","of","List","of","floats",".","The","length","of","the","list","corresponds","to","the","Acoustic","Length","(","T",")",".","Each","value","in","the","list","(","Ti",")","is","a","torch.Tensor","(","U",")",",","representing","1","or","more","confidence","scores",".","U","is","the","number","of","target","tokens","for","the","current","timestep","Ti",".","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",".","The","config","may","further","contain","the","following","sub-dictionaries",":","``","greedy","''",":","max_symbols",":","int",",","describing","the","maximum","number","of","target","tokens","to","decode","per","timestep","during","greedy","decoding",".","Setting","to","larger","values","allows","longer","sentences","to","be","decoded",",","at","the","cost","of","increased","execution","time",".","preserve_frame_confidence",":","Same","as","above",",","overrides","above","value",".","confidence_method_cfg",":","Same","as","above",",","overrides","confidence_cfg.method_cfg",".","``","beam","''",":","beam_size",":","int",",","defining","the","beam","size","for","beam","search",".","Must","be",">","=","1",".","If","beam_size","==","1",",","will","perform","cached","greedy","search",".","This","might","be","slightly","different","results","compared","to","the","greedy","search","above",".","score_norm",":","optional","bool",",","whether","to","normalize","the","returned","beam","score","in","the","hypotheses",".","Set","to","True","by","default",".","return_best_hypothesis",":","optional","bool",",","whether","to","return","just","the","best","hypothesis","or","all","of","the","hypotheses","after","beam","search","has","concluded",".","tsd_max_sym_exp",":","optional","int",",","determines","number","of","symmetric","expansions","of","the","target","symbols","per","timestep","of","the","acoustic","model",".","Larger","values","will","allow","longer","sentences","to","be","decoded",",","at","increased","cost","to","execution","time",".","alsd_max_target_len",":","optional","int","or","float",",","determines","the","potential","maximum","target","sequence","length",".","If","an","integer","is","provided",",","it","can","decode","sequences","of","that","particular","maximum","length",".","If","a","float","is","provided",",","it","can","decode","sequences","of","int","(","alsd_max_target_len","*","seq_len",")",",","where","seq_len","is","the","length","of","the","acoustic","model","output","(","T",")",".","NOTE",":","If","a","float","is","provided",",","it","can","be","greater","than","1","!","By","default",",","a","float","of","2.0","is","used","so","that","a","target","sequence","can","be","at","most","twice","as","long","as","the","acoustic","model","output","length","T.","maes_num_steps",":","Number","of","adaptive","steps","to","take",".","From","the","paper",",","2","steps","is","generally","sufficient",",","and","can","be","reduced","to","1","to","improve","decoding","speed","while","sacrificing","some","accuracy",".","int",">","0.","maes_prefix_alpha",":","Maximum","prefix","length","in","prefix","search",".","Must","be","an","integer",",","and","is","advised","to","keep","this","as","1","in","order","to","reduce","expensive","beam","search","cost","later",".","int",">","=","0.","maes_expansion_beta",":","Maximum","number","of","prefix","expansions","allowed",",","in","addition","to","the","beam","size",".","Effectively",",","the","number","of","hypothesis","=","beam_size","+","maes_expansion_beta",".","Must","be","an","int",">","=","0",",","and","affects","the","speed","of","inference","since","large","values","will","perform","large","beam","search","in","the","next","step",".","maes_expansion_gamma",":","Float","pruning","threshold","used","in","the","prune-by-value","step","when","computing","the","expansions",".","The","default","(","2.3",")","is","selected","from","the","paper",".","It","performs","a","comparison","(","max_log_prob","-","gamma","<","=","log_prob","[","v","]",")","where","v","is","all","vocabulary","indices","in","the","Vocab","set","and","max_log_prob","is","the","``","most","''","likely","token","to","be","predicted",".","Gamma","therefore","provides","a","margin","of","additional","tokens","which","can","be","potential","candidates","for","expansion","apart","from","the","``","most","likely","''","candidate",".","Lower","values","will","reduce","the","number","of","expansions","(","by","increasing","pruning-by-value",",","thereby","improving","speed","but","hurting","accuracy",")",".","Higher","values","will","increase","the","number","of","expansions","(","by","reducing","pruning-by-value",",","thereby","reducing","speed","but","potentially","improving","accuracy",")",".","This","is","a","hyper","parameter","to","be","experimentally","tuned","on","a","validation","set",".","softmax_temperature",":","Scales","the","logits","of","the","joint","prior","to","computing","log_softmax",".","decoder",":","The","Decoder\/Prediction","network","module",".","joint",":","The","Joint","network","module",".","tokenizer",":","The","tokenizer","which","will","be","used","for","decoding","."]
docstr: Compute the most likely language ID (LID) string given the tokens.
  
  Args:
      tokens: List of int representing the token ids.
  
  Returns:
      A decoded LID string.
docstr_tok: ["Compute","the","most","likely","language","ID","(","LID",")","string","given","the","tokens",".","Args",":","tokens",":","List","of","int","representing","the","token","ids",".","Returns",":","A","decoded","LID","string","."]
code: def decode_tokens_to_lang(self, tokens: List[int]) -> str:
      """
      Compute the most likely language ID (LID) string given the tokens.
  
      Args:
          tokens: List of int representing the token ids.
  
      Returns:
          A decoded LID string.
      """
      lang = self.tokenizer.ids_to_lang(tokens)
      return lang
  
imports: import re
  from abc import abstractmethod
  from dataclasses import dataclass, field, is_dataclass
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from omegaconf import OmegaConf
  from nemo.collections.asr.parts.submodules import rnnt_beam_decoding, rnnt_greedy_decoding
  from nemo.collections.asr.parts.utils.asr_confidence_utils import ConfidenceConfig, ConfidenceMixin
  from nemo.collections.asr.parts.utils.rnnt_utils import Hypothesis, NBestHypotheses
  from nemo.collections.common.tokenizers.aggregate_tokenizer import AggregateTokenizer
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.utils import logging
label_desc: Use image node_id 5 for calling the RNNTBPEDecoding obj's underlying member method code with example usage: obj.decode_tokens_to_lang(tokens) and returns: lang