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: E2E forward.
  
  :param torch.Tensor xs_pad: batch of padded input sequences (B, Tmax, idim)
  :param torch.Tensor ilens: batch of lengths of input sequences (B)
  :param torch.Tensor ys_pad: batch of padded token id sequence tensor (B, Lmax)
  :return: loss value
  :rtype: torch.Tensor
code: def forward(self, xs_pad, ilens, ys_pad):
      """E2E forward.
  
      :param torch.Tensor xs_pad: batch of padded input sequences (B, Tmax, idim)
      :param torch.Tensor ilens: batch of lengths of input sequences (B)
      :param torch.Tensor ys_pad: batch of padded token id sequence tensor (B, Lmax)
      :return: loss value
      :rtype: torch.Tensor
      """
      import editdistance
  
      # 0. Frontend
      if self.frontend is not None:
          hs_pad, hlens, mask = self.frontend(
              to_torch_tensor(xs_pad), ilens
          )
          hs_pad, hlens = self.feature_transform(hs_pad, hlens)
      else:
          hs_pad, hlens = xs_pad, ilens
  
      # 1. Encoder
      hs_pad, hlens, _ = self.enc(hs_pad, hlens)
  
      # 2. CTC loss
      if self.mtlalpha == 0:
          self.loss_ctc = None
      else:
          self.loss_ctc = self.ctc(hs_pad, hlens, ys_pad)
  
      # 3. attention loss
      if self.mtlalpha == 1:
          self.loss_att, acc = None, None
      else:
          self.loss_att, acc, _ = self.dec(hs_pad, hlens, ys_pad)
      self.acc = acc
  
      # 4. compute cer without beam search
      if self.mtlalpha == 0 or self.char_list is None:
          cer_ctc = None
      else:
          cers = []
  
          y_hats = self.ctc.argmax(hs_pad).data
          for i, y in enumerate(y_hats):
              y_hat = [x[0] for x in groupby(y)]
              y_true = ys_pad[i]
  
              seq_hat = [
                  self.char_list[int(idx)]
                  for idx in y_hat
                  if int(idx) != -1
              ]
              seq_true = [
                  self.char_list[int(idx)]
                  for idx in y_true
                  if int(idx) != -1
              ]
              seq_hat_text = "".join(seq_hat).replace(self.space, " ")
              seq_hat_text = seq_hat_text.replace(self.blank, "")
              seq_true_text = "".join(seq_true).replace(self.space, " ")
  
              hyp_chars = seq_hat_text.replace(" ", "")
              ref_chars = seq_true_text.replace(" ", "")
              if len(ref_chars) > 0:
                  cers.append(
                      editdistance.eval(hyp_chars, ref_chars)
                      / len(ref_chars)
                  )
  
          cer_ctc = sum(cers) / len(cers) if cers else None
  
      # 5. compute cer/wer
      if self.training or not (self.report_cer or self.report_wer):
          cer, wer = 0.0, 0.0
          # oracle_cer, oracle_wer = 0.0, 0.0
      else:
          if self.recog_args.ctc_weight > 0.0:
              lpz = self.ctc.log_softmax(hs_pad).data
          else:
              lpz = None
  
          word_eds, word_ref_lens, char_eds, char_ref_lens = (
              [],
              [],
              [],
              [],
          )
          nbest_hyps = self.dec.recognize_beam_batch(
              hs_pad,
              torch.tensor(hlens),
              lpz,
              self.recog_args,
              self.char_list,
              self.rnnlm,
          )
          # remove <sos> and <eos>
          y_hats = [
              nbest_hyp[0]["yseq"][1:-1] for nbest_hyp in nbest_hyps
          ]
          for i, y_hat in enumerate(y_hats):
              y_true = ys_pad[i]
  
              seq_hat = [
                  self.char_list[int(idx)]
                  for idx in y_hat
                  if int(idx) != -1
              ]
              seq_true = [
                  self.char_list[int(idx)]
                  for idx in y_true
                  if int(idx) != -1
              ]
              seq_hat_text = "".join(seq_hat).replace(
                  self.recog_args.space, " "
              )
              seq_hat_text = seq_hat_text.replace(
                  self.recog_args.blank, ""
              )
              seq_true_text = "".join(seq_true).replace(
                  self.recog_args.space, " "
              )
  
              hyp_words = seq_hat_text.split()
              ref_words = seq_true_text.split()
              word_eds.append(editdistance.eval(hyp_words, ref_words))
              word_ref_lens.append(len(ref_words))
              hyp_chars = seq_hat_text.replace(" ", "")
              ref_chars = seq_true_text.replace(" ", "")
              char_eds.append(editdistance.eval(hyp_chars, ref_chars))
              char_ref_lens.append(len(ref_chars))
  
          wer = (
              0.0
              if not self.report_wer
              else float(sum(word_eds)) / sum(word_ref_lens)
          )
          cer = (
              0.0
              if not self.report_cer
              else float(sum(char_eds)) / sum(char_ref_lens)
          )
  
      alpha = self.mtlalpha
      if alpha == 0:
          self.loss = self.loss_att
          loss_att_data = float(self.loss_att)
          loss_ctc_data = None
      elif alpha == 1:
          self.loss = self.loss_ctc
          loss_att_data = None
          loss_ctc_data = float(self.loss_ctc)
      else:
          self.loss = (
              alpha * self.loss_ctc + (1 - alpha) * self.loss_att
          )
          loss_att_data = float(self.loss_att)
          loss_ctc_data = float(self.loss_ctc)
  
      loss_data = float(self.loss)
      if loss_data < CTC_LOSS_THRESHOLD and not math.isnan(loss_data):
          self.reporter.report(
              loss_ctc_data,
              loss_att_data,
              acc,
              cer_ctc,
              cer,
              wer,
              loss_data,
          )
      else:
          logging.warning("loss (=%f) is not correct", loss_data)
      return self.loss
  
imports: import argparse
  import logging
  import math
  import os
  from itertools import groupby
  import chainer
  import numpy
  import torch
  from chainer import reporter
  from espnet.nets.asr_interface import ASRInterface
  from espnet.nets.e2e_asr_common import label_smoothing_dist
  from espnet.nets.pytorch_backend.ctc import ctc_for
  from espnet.nets.pytorch_backend.frontends.feature_transform import feature_transform_for
  from espnet.nets.pytorch_backend.frontends.frontend import frontend_for
  from espnet.nets.pytorch_backend.initialization import lecun_normal_init_parameters, set_forget_bias_to_one
  from espnet.nets.pytorch_backend.nets_utils import get_subsample, pad_list, to_device, to_torch_tensor
  from espnet.nets.pytorch_backend.rnn.argument import add_arguments_rnn_attention_common, add_arguments_rnn_decoder_common, add_arguments_rnn_encoder_common
  from espnet.nets.pytorch_backend.rnn.attentions import att_for
  from espnet.nets.pytorch_backend.rnn.decoders import decoder_for
  from espnet.nets.pytorch_backend.rnn.encoders import encoder_for
  from espnet.nets.scorers.ctc import CTCPrefixScorer
  from espnet.utils.fill_missing_args import fill_missing_args
label_desc: Use image node_id 8 for calling the E2E obj's underlying member method code with example usage: obj.forward(xs_pad, ilens, ys_pad) and returns: self