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: Select CTC states according to best ids
  
  :param state    : CTC state
  :param best_ids : index numbers selected by beam pruning (B, W)
  :return selected_state
docstr_tok: ["Select","CTC","states","according","to","best","ids",":","param","state",":","CTC","state",":","param","best_ids",":","index","numbers","selected","by","beam","pruning","(","B",",","W",")",":","return","selected_state"]
code: def index_select_state(self, state, best_ids):
      """Select CTC states according to best ids
  
      :param state    : CTC state
      :param best_ids : index numbers selected by beam pruning (B, W)
      :return selected_state
      """
      r, s, f_min, f_max, scoring_idmap = state
      # convert ids to BHO space
      n_bh = len(s)
      n_hyps = n_bh // self.batch
      vidx = (
          best_ids + (self.idx_b * (n_hyps * self.odim)).view(-1, 1)
      ).view(-1)
      # select hypothesis scores
      s_new = torch.index_select(s.view(-1), 0, vidx)
      s_new = (
          s_new.view(-1, 1).repeat(1, self.odim).view(n_bh, self.odim)
      )
      # convert ids to BHS space (S: scoring_num)
      if scoring_idmap is not None:
          snum = self.scoring_num
          hyp_idx = (
              best_ids // self.odim + (self.idx_b * n_hyps).view(-1, 1)
          ).view(-1)
          label_ids = torch.fmod(best_ids, self.odim).view(-1)
          score_idx = scoring_idmap[hyp_idx, label_ids]
          score_idx[score_idx == -1] = 0
          vidx = score_idx + hyp_idx * snum
      else:
          snum = self.odim
      # select forward probabilities
      r_new = torch.index_select(
          r.view(-1, 2, n_bh * snum), 2, vidx
      ).view(-1, 2, n_bh)
      return r_new, s_new, f_min, f_max
  
file_path: espnet/espnet/nets/ctc_prefix_score.py
imports: import numpy
  import torch
label_desc: Use image node_id 3 for calling the CTCPrefixScoreTH obj's underlying member method code with example usage: obj.index_select_state(state, best_ids) and returns: r_new,  s_new,  f_min,  f_max