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: Forward pass in the auxiliary ASR task.
  
  :param torch.Tensor hs_pad: batch of padded source sequences (B, Tmax, idim)
  :param torch.Tensor hlens: batch of lengths of input sequences (B)
  :param torch.Tensor ys_pad: batch of padded target sequences (B, Lmax)
  :return: ASR attention loss value
  :rtype: torch.Tensor
  :return: accuracy in ASR attention decoder
  :rtype: float
  :return: ASR CTC loss value
  :rtype: torch.Tensor
  :return: character error rate from CTC prediction
  :rtype: float
  :return: character error rate from attetion decoder prediction
  :rtype: float
  :return: word error rate from attetion decoder prediction
  :rtype: float
code: def forward_asr(self, hs_pad, hlens, ys_pad):
      """Forward pass in the auxiliary ASR task.
  
      :param torch.Tensor hs_pad: batch of padded source sequences (B, Tmax, idim)
      :param torch.Tensor hlens: batch of lengths of input sequences (B)
      :param torch.Tensor ys_pad: batch of padded target sequences (B, Lmax)
      :return: ASR attention loss value
      :rtype: torch.Tensor
      :return: accuracy in ASR attention decoder
      :rtype: float
      :return: ASR CTC loss value
      :rtype: torch.Tensor
      :return: character error rate from CTC prediction
      :rtype: float
      :return: character error rate from attetion decoder prediction
      :rtype: float
      :return: word error rate from attetion decoder prediction
      :rtype: float
      """
      import editdistance
  
      loss_att, loss_ctc = 0.0, 0.0
      acc = None
      cer, wer = None, None
      cer_ctc = None
      if self.asr_weight == 0:
          return loss_att, acc, loss_ctc, cer_ctc, cer, wer
  
      # attention
      if self.mtlalpha < 1:
          loss_asr, acc_asr, _ = self.dec_asr(hs_pad, hlens, ys_pad)
  
          # Compute wer and cer
          if not self.training and (self.report_cer or self.report_wer):
              if self.mtlalpha > 0 and 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_asr = self.dec_asr.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_asr
              ]
              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)
              )
  
      # CTC
      if self.mtlalpha > 0:
          loss_ctc = self.ctc(hs_pad, hlens, ys_pad)
  
          # Compute cer with CTC prediction
          if self.char_list is not None:
              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
  
      return loss_att, acc, loss_ctc, cer_ctc, cer, wer
  
imports: import argparse
  import copy
  import logging
  import math
  import os
  from itertools import groupby
  import chainer
  import nltk
  import numpy
  import torch
  from chainer import reporter
  from espnet.nets.e2e_asr_common import label_smoothing_dist
  from espnet.nets.pytorch_backend.ctc import CTC
  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.st_interface import STInterface
  from espnet.utils.fill_missing_args import fill_missing_args
label_desc: Use image node_id 9 for calling the E2E obj's underlying member method code with example usage: obj.forward_asr(hs_pad, hlens, ys_pad) and returns: loss_att,  acc,  loss_ctc,  cer_ctc,  cer,  wer, loss_att,  acc,  loss_ctc,  cer_ctc,  cer,  wer