class_docstr: CTC Prefix Beam Search is based on the paper
  `First-Pass Large Vocabulary Continuous Speech Recognition using Bi-Directional Recurrent DNNs`
  by Awni Y. Hannun and al (https://arxiv.org/abs/1408.2873).
  
  The implementation keep tracks of the blank and non-blank probabilities.
  It also suppors n-gram scoring on words and SentencePiece tokens. The input
  is expected to be a log-probabilities tensor of shape [batch, time, vocab_size].
  
  Several heuristics are implemented to speed up the decoding process:
  - pruning of the beam : the beams are pruned if their score is lower than
      the best beam score minus the beam_prune_logp
  - pruning of the tokens : the tokens are pruned if their score is lower than
      the token_prune_min_logp
  - pruning of the history : the beams are pruned if they are the same over
      max_ngram history
  - skipping of the blank : the frame is skipped if the blank probability is
      higher than the blank_skip_threshold
  
  Note: The CTCPrefixBeamSearcher can be more unstable than the CTCBeamSearcher
  or the TorchAudioCTCPrefixBeamSearch searcher. Please, use it with caution
  and check the results carefully.
  
  Note: if the Acoustic Model is not trained, the Beam Search will
  take a lot of time. We do recommand to use Greedy Search during validation
  until the model is fully trained and ready to be evaluated on test sets.
  
  Note: This implementation does not provide the time alignment of the
  hypothesis. If you need it, please use the CTCBeamSearcher.
  
  Arguments
  ---------
  **kwargs
      see CTCBaseSearcher, arguments are directly passed.
  
  Example
  -------
  >>> import torch
  >>> from speechbrain.decoders import CTCPrefixBeamSearcher
  >>> probs = torch.tensor([[[0.2, 0.0, 0.8],
  ...                   [0.4, 0.0, 0.6]]])
  >>> log_probs = torch.log(probs)
  >>> lens = torch.tensor([1.0])
  >>> blank_index = 2
  >>> vocab_list = ['a', 'b', '-']
  >>> searcher = CTCPrefixBeamSearcher(blank_index=blank_index, vocab_list=vocab_list)
  >>> hyps = searcher(probs, lens)
class_docstr_tok: ["CTC","Prefix","Beam","Search","is","based","on","the","paper","`","First-Pass","Large","Vocabulary","Continuous","Speech","Recognition","using","Bi-Directional","Recurrent","DNNs","`","by","Awni","Y.","Hannun","and","al","(","https",":","\/\/arxiv.org\/abs\/1408.2873",")",".","The","implementation","keep","tracks","of","the","blank","and","non-blank","probabilities",".","It","also","suppors","n-gram","scoring","on","words","and","SentencePiece","tokens",".","The","input","is","expected","to","be","a","log-probabilities","tensor","of","shape","[","batch",",","time",",","vocab_size","]",".","Several","heuristics","are","implemented","to","speed","up","the","decoding","process",":","-","pruning","of","the","beam",":","the","beams","are","pruned","if","their","score","is","lower","than","the","best","beam","score","minus","the","beam_prune_logp","-","pruning","of","the","tokens",":","the","tokens","are","pruned","if","their","score","is","lower","than","the","token_prune_min_logp","-","pruning","of","the","history",":","the","beams","are","pruned","if","they","are","the","same","over","max_ngram","history","-","skipping","of","the","blank",":","the","frame","is","skipped","if","the","blank","probability","is","higher","than","the","blank_skip_threshold","Note",":","The","CTCPrefixBeamSearcher","can","be","more","unstable","than","the","CTCBeamSearcher","or","the","TorchAudioCTCPrefixBeamSearch","searcher",".","Please",",","use","it","with","caution","and","check","the","results","carefully",".","Note",":","if","the","Acoustic","Model","is","not","trained",",","the","Beam","Search","will","take","a","lot","of","time",".","We","do","recommand","to","use","Greedy","Search","during","validation","until","the","model","is","fully","trained","and","ready","to","be","evaluated","on","test","sets",".","Note",":","This","implementation","does","not","provide","the","time","alignment","of","the","hypothesis",".","If","you","need","it",",","please","use","the","CTCBeamSearcher",".","Arguments","--","--","--","--","-","*","*","kwargs","see","CTCBaseSearcher",",","arguments","are","directly","passed",".","Example","--","--","--","-",">",">",">","import","torch",">",">",">","from","speechbrain.decoders","import","CTCPrefixBeamSearcher",">",">",">","probs","=","torch.tensor","(","[","[","[","0.2",",","0.0",",","0.8","]",",","...","[","0.4",",","0.0",",","0.6","]","]","]",")",">",">",">","log_probs","=","torch.log","(","probs",")",">",">",">","lens","=","torch.tensor","(","[","1.0","]",")",">",">",">","blank_index","=","2",">",">",">","vocab_list","=","[","'","a","'",",","'","b","'",",","'-","'","]",">",">",">","searcher","=","CTCPrefixBeamSearcher","(","blank_index=blank_index",",","vocab_list=vocab_list",")",">",">",">","hyps","=","searcher","(","probs",",","lens",")"]
code: def __init__(self, **kwargs):
      super().__init__(**kwargs)
  
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 1 to create a new CTCPrefixBeamSearcher object from inherited base classes: CTCBaseSearcher with example: obj = CTCPrefixBeamSearcher()