class_docstr: CTCBaseSearcher class to be inherited by other
  CTC beam searchers.
  
  This class provides the basic functionalities for
  CTC beam search decoding.
  
  The space_token is required with a non-sentencepiece vocabulary list
  if your transcription is expecting to contain spaces.
  
  Arguments
  ---------
  blank_index : int
      The index of the blank token.
  vocab_list : list
      The list of the vocabulary tokens.
  space_token : int, optional
      The index of the space token. (default: -1)
  kenlm_model_path : str, optional
      The path to the kenlm model. Use .bin for a faster loading.
      If None, no language model will be used. (default: None)
  unigrams : list, optional
      The list of known word unigrams. (default: None)
  alpha : float
      Weight for language model during shallow fusion. (default: 0.5)
  beta : float
      Weight for length score adjustment of during scoring. (default: 1.5)
  unk_score_offset : float
      Amount of log score offset for unknown tokens. (default: -10.0)
  score_boundary : bool
      Whether to have kenlm respect boundaries when scoring. (default: True)
  beam_size : int, optional
      The width of the beam. (default: 100)
  beam_prune_logp : float, optional
      The pruning threshold for the beam. (default: -10.0)
  token_prune_min_logp : float, optional
      The pruning threshold for the tokens. (default: -5.0)
  prune_history : bool, optional
      Whether to prune the history. (default: True)
      Note: when using topk > 1, this should be set to False as
      it is pruning a lot of beams.
  blank_skip_threshold : float, optional
      Skip frames if log_prob(blank) > log(blank_skip_threshold), to speed up decoding.
      Note: This is only used when using the CUDA decoder, and it might worsen the WER/CER results. Use it at your own risk. (default: 1.0)
  topk : int, optional
      The number of top hypotheses to return. (default: 1)
  spm_token: str, optional
      The sentencepiece token. (default: "▁")
  
  Example
  -------
  >>> blank_index = 0
  >>> vocab_list = ['blank', 'a', 'b', 'c', ' ']
  >>> space_token = ' '
  >>> kenlm_model_path = None
  >>> unigrams = None
  >>> beam_size = 100
  >>> beam_prune_logp = -10.0
  >>> token_prune_min_logp = -5.0
  >>> prune_history = True
  >>> blank_skip_threshold = 1.0
  >>> topk = 1
  >>> searcher = CTCBaseSearcher(
  ...     blank_index=blank_index,
  ...     vocab_list=vocab_list,
  ...     space_token=space_token,
  ...     kenlm_model_path=kenlm_model_path,
  ...     unigrams=unigrams,
  ...     beam_size=beam_size,
  ...     beam_prune_logp=beam_prune_logp,
  ...     token_prune_min_logp=token_prune_min_logp,
  ...     prune_history=prune_history,
  ...     blank_skip_threshold=blank_skip_threshold,
  ...     topk=topk,
  ... )
class_docstr_tok: ["CTCBaseSearcher","class","to","be","inherited","by","other","CTC","beam","searchers",".","This","class","provides","the","basic","functionalities","for","CTC","beam","search","decoding",".","The","space_token","is","required","with","a","non-sentencepiece","vocabulary","list","if","your","transcription","is","expecting","to","contain","spaces",".","Arguments","--","--","--","--","-","blank_index",":","int","The","index","of","the","blank","token",".","vocab_list",":","list","The","list","of","the","vocabulary","tokens",".","space_token",":","int",",","optional","The","index","of","the","space","token",".","(","default",":","-1",")","kenlm_model_path",":","str",",","optional","The","path","to","the","kenlm","model",".","Use",".bin","for","a","faster","loading",".","If","None",",","no","language","model","will","be","used",".","(","default",":","None",")","unigrams",":","list",",","optional","The","list","of","known","word","unigrams",".","(","default",":","None",")","alpha",":","float","Weight","for","language","model","during","shallow","fusion",".","(","default",":","0.5",")","beta",":","float","Weight","for","length","score","adjustment","of","during","scoring",".","(","default",":","1.5",")","unk_score_offset",":","float","Amount","of","log","score","offset","for","unknown","tokens",".","(","default",":","-10.0",")","score_boundary",":","bool","Whether","to","have","kenlm","respect","boundaries","when","scoring",".","(","default",":","True",")","beam_size",":","int",",","optional","The","width","of","the","beam",".","(","default",":","100",")","beam_prune_logp",":","float",",","optional","The","pruning","threshold","for","the","beam",".","(","default",":","-10.0",")","token_prune_min_logp",":","float",",","optional","The","pruning","threshold","for","the","tokens",".","(","default",":","-5.0",")","prune_history",":","bool",",","optional","Whether","to","prune","the","history",".","(","default",":","True",")","Note",":","when","using","topk",">","1",",","this","should","be","set","to","False","as","it","is","pruning","a","lot","of","beams",".","blank_skip_threshold",":","float",",","optional","Skip","frames","if","log_prob","(","blank",")",">","log","(","blank_skip_threshold",")",",","to","speed","up","decoding",".","Note",":","This","is","only","used","when","using","the","CUDA","decoder",",","and","it","might","worsen","the","WER\/CER","results",".","Use","it","at","your","own","risk",".","(","default",":","1.0",")","topk",":","int",",","optional","The","number","of","top","hypotheses","to","return",".","(","default",":","1",")","spm_token",":","str",",","optional","The","sentencepiece","token",".","(","default",":","``","\u2581","''",")","Example","--","--","--","-",">",">",">","blank_index","=","0",">",">",">","vocab_list","=","[","'blank","'",",","'","a","'",",","'","b","'",",","'","c","'",",","'","'","]",">",">",">","space_token","=","'","'",">",">",">","kenlm_model_path","=","None",">",">",">","unigrams","=","None",">",">",">","beam_size","=","100",">",">",">","beam_prune_logp","=","-10.0",">",">",">","token_prune_min_logp","=","-5.0",">",">",">","prune_history","=","True",">",">",">","blank_skip_threshold","=","1.0",">",">",">","topk","=","1",">",">",">","searcher","=","CTCBaseSearcher","(","...","blank_index=blank_index",",","...","vocab_list=vocab_list",",","...","space_token=space_token",",","...","kenlm_model_path=kenlm_model_path",",","...","unigrams=unigrams",",","...","beam_size=beam_size",",","...","beam_prune_logp=beam_prune_logp",",","...","token_prune_min_logp=token_prune_min_logp",",","...","prune_history=prune_history",",","...","blank_skip_threshold=blank_skip_threshold",",","...","topk=topk",",","...",")"]
docstr: Perform a single step of decoding.
  
  Arguments
  ---------
  log_probs : torch.Tensor
      The log probabilities of the CTC output.
  cached_lm_scores : dict
      The cached language model scores.
  cached_p_lm_scores : dict
      The cached prefix language model scores.
  beams : list
      The list of the beams.
  processed_frames : int
      The start frame of the current decoding step.
  force_next_word : bool, optional (default: False)
      Whether to force the next word.
  is_end : bool, optional (default: False)
      Whether the end of the sequence has been reached.
  
  Returns
  -------
  list
      The list of CTCBeam.
docstr_tok: ["Perform","a","single","step","of","decoding",".","Arguments","--","--","--","--","-","log_probs",":","torch.Tensor","The","log","probabilities","of","the","CTC","output",".","cached_lm_scores",":","dict","The","cached","language","model","scores",".","cached_p_lm_scores",":","dict","The","cached","prefix","language","model","scores",".","beams",":","list","The","list","of","the","beams",".","processed_frames",":","int","The","start","frame","of","the","current","decoding","step",".","force_next_word",":","bool",",","optional","(","default",":","False",")","Whether","to","force","the","next","word",".","is_end",":","bool",",","optional","(","default",":","False",")","Whether","the","end","of","the","sequence","has","been","reached",".","Returns","--","--","--","-","list","The","list","of","CTCBeam","."]
code: def partial_decode_beams(
      self,
      log_probs: torch.Tensor,
      cached_lm_scores: dict,
      cached_p_lm_scores: dict,
      beams: List[CTCBeam],
      processed_frames: int,
      force_next_word=False,
      is_end=False,
  ) -> List[CTCBeam]:
      """Perform a single step of decoding.
  
      Arguments
      ---------
      log_probs : torch.Tensor
          The log probabilities of the CTC output.
      cached_lm_scores : dict
          The cached language model scores.
      cached_p_lm_scores : dict
          The cached prefix language model scores.
      beams : list
          The list of the beams.
      processed_frames : int
          The start frame of the current decoding step.
      force_next_word : bool, optional (default: False)
          Whether to force the next word.
      is_end : bool, optional (default: False)
          Whether the end of the sequence has been reached.
  
      Returns
      -------
      list
          The list of CTCBeam.
      """
      beams = self.partial_decoding(
          log_probs,
          beams,
          cached_lm_scores,
          cached_p_lm_scores,
          processed_frames=processed_frames,
      )
  
      trimmed_beams = self.finalize_decoding(
          beams,
          cached_lm_scores,
          cached_p_lm_scores,
          force_next_word=force_next_word,
          is_end=is_end,
      )
  
      return trimmed_beams
  
imports: from itertools import groupby
  from speechbrain.dataio.dataio import length_to_mask
  import math
  import dataclasses
  import numpy
  import heapq
  import logging
  import torch
  import warnings
  from typing import Dict, List, Optional, Union, Any, Tuple
label_desc: Use image node_id 11 for calling the CTCBaseSearcher obj's underlying member method code with example usage: obj.partial_decode_beams(log_probs, cached_lm_scores, cached_p_lm_scores, beams, processed_frames, force_next_word, is_end) and returns: trimmed_beams