class_docstr: Decoder interface wrapper for CTCPrefixScore.
class_docstr_tok: ["Decoder","interface","wrapper","for","CTCPrefixScore","."]
docstr: Select state with relative ids in the main beam search.
  
  Args:
      state: Decoder state for prefix tokens
      i (int): Index to select a state in the main beam search
      new_id (int): New label id to select a state if necessary
  
  Returns:
      state: pruned state
docstr_tok: ["Select","state","with","relative","ids","in","the","main","beam","search",".","Args",":","state",":","Decoder","state","for","prefix","tokens","i","(","int",")",":","Index","to","select","a","state","in","the","main","beam","search","new_id","(","int",")",":","New","label","id","to","select","a","state","if","necessary","Returns",":","state",":","pruned","state"]
code: def select_state(self, state, i, new_id=None):
      """Select state with relative ids in the main beam search.
  
      Args:
          state: Decoder state for prefix tokens
          i (int): Index to select a state in the main beam search
          new_id (int): New label id to select a state if necessary
  
      Returns:
          state: pruned state
  
      """
      if type(state) is tuple:
          if len(state) == 2:  # for CTCPrefixScore
              sc, st = state
              return sc[i], st[i]
          else:  # for CTCPrefixScoreTH (need new_id > 0)
              r, log_psi, f_min, f_max, scoring_idmap = state
              s = log_psi[i, new_id].expand(log_psi.size(1))
              if scoring_idmap is not None:
                  return (
                      r[:, :, i, scoring_idmap[i, new_id]],
                      s,
                      f_min,
                      f_max,
                  )
              else:
                  return r[:, :, i, new_id], s, f_min, f_max
      return None if state is None else state[i]
  
file_path: espnet/espnet/nets/scorers/ctc.py
imports: import numpy
  import torch
  from espnet.nets.ctc_prefix_score import CTCPrefixScore, CTCPrefixScoreTH
  from espnet.nets.scorer_interface import BatchPartialScorerInterface
label_desc: Use image node_id 3 for calling the CTCPrefixScorer obj's underlying member method code with example usage: obj.select_state(state, i, new_id) and returns: unknown, sc,  st, r,  s,  f_min,  f_max, r,  s,  f_min,  f_max