class_docstr: Batch processing of CTCPrefixScore
  
  which is based on Algorithm 2 in WATANABE et al.
  "HYBRID CTC/ATTENTION ARCHITECTURE FOR END-TO-END SPEECH RECOGNITION,"
  but extended to efficiently compute the label probablities for multiple
  hypotheses simultaneously
  See also Seki et al. "Vectorized Beam Search for CTC-Attention-Based
  Speech Recognition," In INTERSPEECH (pp. 3825-3829), 2019.
class_docstr_tok: ["Batch","processing","of","CTCPrefixScore","which","is","based","on","Algorithm","2","in","WATANABE","et","al",".","``","HYBRID","CTC\/ATTENTION","ARCHITECTURE","FOR","END-TO-END","SPEECH","RECOGNITION",",","''","but","extended","to","efficiently","compute","the","label","probablities","for","multiple","hypotheses","simultaneously","See","also","Seki","et","al",".","``","Vectorized","Beam","Search","for","CTC-Attention-Based","Speech","Recognition",",","''","In","INTERSPEECH","(","pp",".","3825-3829",")",",","2019","."]
docstr: Extend CTC prob.
  
  :param torch.Tensor x: input label posterior sequences (B, T, O)
docstr_tok: ["Extend","CTC","prob",".",":","param","torch.Tensor","x",":","input","label","posterior","sequences","(","B",",","T",",","O",")"]
code: def extend_prob(self, x):
      """Extend CTC prob.
  
      :param torch.Tensor x: input label posterior sequences (B, T, O)
      """
  
      if self.x.shape[1] < x.shape[1]:  # self.x (2,T,B,O); x (B,T,O)
          # Pad the rest of posteriors in the batch
          # TODO(takaaki-hori): need a better way without for-loops
          xlens = [x.size(1)]
          for i, l in enumerate(xlens):
              if l < self.input_length:
                  x[i, l:, :] = self.logzero
                  x[i, l:, self.blank] = 0
          tmp_x = self.x
          xn = x.transpose(0, 1)  # (B, T, O) -> (T, B, O)
          xb = (
              xn[:, :, self.blank]
              .unsqueeze(2)
              .expand(-1, -1, self.odim)
          )
          self.x = torch.stack([xn, xb])  # (2, T, B, O)
          self.x[:, : tmp_x.shape[1], :, :] = tmp_x
          self.input_length = x.size(1)
          self.end_frames = torch.as_tensor(xlens) - 1
  
file_path: espnet/espnet/nets/ctc_prefix_score.py
imports: import numpy
  import torch
label_desc: Use image node_id 4 for calling the CTCPrefixScoreTH obj's underlying member method code with example usage: obj.extend_prob(x) without return types