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 source sequences (B, Tmax)
  :param torch.Tensor ilens: batch of lengths of source sequences (B)
  :param torch.Tensor ys_pad: batch of padded target sequences (B, Lmax)
  :rtype: torch.Tensor
  :return: attention loss value
  :rtype: torch.Tensor
  :return: accuracy in attention decoder
  :rtype: float
docstr_tok: ["E2E","forward",".",":","param","torch.Tensor","xs_pad",":","batch","of","padded","source","sequences","(","B",",","Tmax",")",":","param","torch.Tensor","ilens",":","batch","of","lengths","of","source","sequences","(","B",")",":","param","torch.Tensor","ys_pad",":","batch","of","padded","target","sequences","(","B",",","Lmax",")",":","rtype",":","torch.Tensor",":","return",":","attention","loss","value",":","rtype",":","torch.Tensor",":","return",":","accuracy","in","attention","decoder",":","rtype",":","float"]
code: def forward(self, xs_pad, ilens, ys_pad):
      """E2E forward.
  
      :param torch.Tensor xs_pad: batch of padded source sequences (B, Tmax)
      :param torch.Tensor ilens: batch of lengths of source sequences (B)
      :param torch.Tensor ys_pad: batch of padded target sequences (B, Lmax)
      :rtype: torch.Tensor
      :return: attention loss value
      :rtype: torch.Tensor
      :return: accuracy in attention decoder
      :rtype: float
      """
      # 1. forward encoder
      xs_pad = xs_pad[:, : max(ilens)]  # for data parallel
      src_mask = (
          (~make_pad_mask(ilens.tolist()))
          .to(xs_pad.device)
          .unsqueeze(-2)
      )
      xs_pad, ys_pad = self.target_forcing(xs_pad, ys_pad)
      hs_pad, hs_mask = self.encoder(xs_pad, src_mask)
  
      # 2. forward decoder
      ys_in_pad, ys_out_pad = add_sos_eos(
          ys_pad, self.sos, self.eos, self.ignore_id
      )
      ys_mask = target_mask(ys_in_pad, self.ignore_id)
      pred_pad, pred_mask = self.decoder(
          ys_in_pad, ys_mask, hs_pad, hs_mask
      )
  
      # 3. compute attention loss
      self.loss = self.criterion(pred_pad, ys_out_pad)
      self.acc = th_accuracy(
          pred_pad.view(-1, self.odim),
          ys_out_pad,
          ignore_label=self.ignore_id,
      )
  
      # 4. compute corpus-level bleu in a mini-batch
      if self.training:
          self.bleu = None
      else:
          ys_hat = pred_pad.argmax(dim=-1)
          self.bleu = self.error_calculator(ys_hat.cpu(), ys_pad.cpu())
  
      loss_data = float(self.loss)
      if self.normalize_length:
          self.ppl = np.exp(loss_data)
      else:
          batch_size = ys_out_pad.size(0)
          ys_out_pad = ys_out_pad.view(-1)
          ignore = ys_out_pad == self.ignore_id  # (B*T,)
          total_n_tokens = len(ys_out_pad) - ignore.sum().item()
          self.ppl = np.exp(loss_data * batch_size / total_n_tokens)
      if not math.isnan(loss_data):
          self.reporter.report(loss_data, self.acc, self.ppl, self.bleu)
      else:
          logging.warning("loss (=%f) is not correct", loss_data)
      return self.loss
  
imports: import logging
  import math
  from argparse import Namespace
  import numpy
  import torch
  from espnet.nets.e2e_asr_common import end_detect
  from espnet.nets.e2e_mt_common import ErrorCalculator
  from espnet.nets.mt_interface import MTInterface
  from espnet.nets.pytorch_backend.e2e_mt import Reporter
  from espnet.nets.pytorch_backend.nets_utils import get_subsample, make_pad_mask, th_accuracy, to_device
  from espnet.nets.pytorch_backend.transformer.add_sos_eos import add_sos_eos
  from espnet.nets.pytorch_backend.transformer.argument import add_arguments_transformer_common
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.decoder import Decoder
  from espnet.nets.pytorch_backend.transformer.encoder import Encoder
  from espnet.nets.pytorch_backend.transformer.initializer import initialize
  from espnet.nets.pytorch_backend.transformer.label_smoothing_loss import LabelSmoothingLoss
  from espnet.nets.pytorch_backend.transformer.mask import subsequent_mask, target_mask
  from espnet.nets.pytorch_backend.transformer.plot import PlotAttentionReport
  from espnet.utils.fill_missing_args import fill_missing_args
label_desc: Use image node_id 5 for calling the E2E obj's underlying member method code with example usage: obj.forward(xs_pad, ilens, ys_pad) and returns: self