class_docstr: E2E module.
  
  :param int idim: dimension of inputs
  :param int odim: dimension of outputs
  :param Namespace args: argument Namespace containing options
class_docstr_tok: ["E2E","module",".",":","param","int","idim",":","dimension","of","inputs",":","param","int","odim",":","dimension","of","outputs",":","param","Namespace","args",":","argument","Namespace","containing","options"]
docstr: Recognize input speech.
  
  :param ndnarray x: input acoustic feature (B, T, D) or (T, D)
  :param Namespace recog_args: argment Namespace contraining options
  :param list char_list: list of characters
  :param torch.nn.Module rnnlm: language model module
  :return: decoding result
  :rtype: list
docstr_tok: ["Recognize","input","speech",".",":","param","ndnarray","x",":","input","acoustic","feature","(","B",",","T",",","D",")","or","(","T",",","D",")",":","param","Namespace","recog_args",":","argment","Namespace","contraining","options",":","param","list","char_list",":","list","of","characters",":","param","torch.nn.Module","rnnlm",":","language","model","module",":","return",":","decoding","result",":","rtype",":","list"]
code: def recognize(self, x, recog_args, char_list=None, rnnlm=None):
      """Recognize input speech.
  
      :param ndnarray x: input acoustic feature (B, T, D) or (T, D)
      :param Namespace recog_args: argment Namespace contraining options
      :param list char_list: list of characters
      :param torch.nn.Module rnnlm: language model module
      :return: decoding result
      :rtype: list
      """
  
      def num2str(char_list, mask_token, mask_char="_"):
          def f(yl):
              cl = [
                  char_list[y] if y != mask_token else mask_char
                  for y in yl
              ]
              return "".join(cl).replace("<space>", " ")
  
          return f
  
      n2s = num2str(char_list, self.mask_token)
  
      self.eval()
      h = self.encode(x).unsqueeze(0)
  
      input_len = h.squeeze(0)
      logging.info("input lengths: " + str(input_len.size(0)))
  
      # greedy ctc outputs
      ctc_probs, ctc_ids = torch.exp(self.ctc.log_softmax(h)).max(
          dim=-1
      )
      y_hat = torch.stack([x[0] for x in groupby(ctc_ids[0])])
      y_idx = torch.nonzero(y_hat != 0).squeeze(-1)
  
      # calculate token-level ctc probabilities by taking
      # the maximum probability of consecutive frames with
      # the same ctc symbols
      probs_hat = []
      cnt = 0
      for i, y in enumerate(y_hat.tolist()):
          probs_hat.append(-1)
          while cnt < ctc_ids.shape[1] and y == ctc_ids[0][cnt]:
              if probs_hat[i] < ctc_probs[0][cnt]:
                  probs_hat[i] = ctc_probs[0][cnt].item()
              cnt += 1
      probs_hat = torch.from_numpy(numpy.array(probs_hat))
  
      # mask ctc outputs based on ctc probabilities
      p_thres = recog_args.maskctc_probability_threshold
      mask_idx = torch.nonzero(probs_hat[y_idx] < p_thres).squeeze(-1)
      confident_idx = torch.nonzero(
          probs_hat[y_idx] >= p_thres
      ).squeeze(-1)
      mask_num = len(mask_idx)
  
      y_in = (
          torch.zeros(1, len(y_idx), dtype=torch.long) + self.mask_token
      )
      y_in[0][confident_idx] = y_hat[y_idx][confident_idx]
  
      logging.info("ctc:{}".format(n2s(y_in[0].tolist())))
  
      # iterative decoding
      if not mask_num == 0:
          K = recog_args.maskctc_n_iterations
          num_iter = K if mask_num >= K and K > 0 else mask_num
  
          for t in range(num_iter - 1):
              pred, _ = self.decoder(y_in, None, h, None)
              pred_score, pred_id = pred[0][mask_idx].max(dim=-1)
              cand = torch.topk(pred_score, mask_num // num_iter, -1)[1]
              y_in[0][mask_idx[cand]] = pred_id[cand]
              mask_idx = torch.nonzero(
                  y_in[0] == self.mask_token
              ).squeeze(-1)
  
              logging.info("msk:{}".format(n2s(y_in[0].tolist())))
  
          # predict leftover masks (|masks| < mask_num // num_iter)
          pred, pred_mask = self.decoder(y_in, None, h, None)
          y_in[0][mask_idx] = pred[0][mask_idx].argmax(dim=-1)
  
          logging.info("msk:{}".format(n2s(y_in[0].tolist())))
  
      ret = y_in.tolist()[0]
      hyp = {"score": 0.0, "yseq": [self.sos] + ret + [self.eos]}
  
      return [hyp]
  
file_path: espnet/espnet/nets/pytorch_backend/e2e_asr_maskctc.py
imports: import logging
  import math
  from distutils.util import strtobool
  from itertools import groupby
  import numpy
  import torch
  from espnet.nets.pytorch_backend.conformer.argument import add_arguments_conformer_common
  from espnet.nets.pytorch_backend.conformer.encoder import Encoder
  from espnet.nets.pytorch_backend.e2e_asr import CTC_LOSS_THRESHOLD
  from espnet.nets.pytorch_backend.e2e_asr_transformer import E2E
  from espnet.nets.pytorch_backend.maskctc.add_mask_token import mask_uniform
  from espnet.nets.pytorch_backend.maskctc.mask import square_mask
  from espnet.nets.pytorch_backend.nets_utils import make_non_pad_mask, th_accuracy
label_desc: Use image node_id 5 for calling the E2E obj's underlying member method code with example usage: obj.recognize(x, recog_args, char_list, rnnlm) and returns: list, f, str