class_docstr: E2E module.
  
  Args:
      idim (int): Input dimmensions.
      odim (int): Output dimmensions.
      args (Namespace): Training config.
      ignore_id (int, optional): Id for ignoring a character.
      flag_return (bool, optional): If true, return a list with (loss,
      loss_ctc, loss_att, acc) in forward. Otherwise, return loss.
class_docstr_tok: ["E2E","module",".","Args",":","idim","(","int",")",":","Input","dimmensions",".","odim","(","int",")",":","Output","dimmensions",".","args","(","Namespace",")",":","Training","config",".","ignore_id","(","int",",","optional",")",":","Id","for","ignoring","a","character",".","flag_return","(","bool",",","optional",")",":","If","true",",","return","a","list","with","(","loss",",","loss_ctc",",","loss_att",",","acc",")","in","forward",".","Otherwise",",","return","loss","."]
docstr: E2E forward propagation.
  
  Args:
      xs (chainer.Variable): Batch of padded character ids. (B, Tmax)
      ilens (chainer.Variable): Batch of length of each input batch. (B,)
      ys (chainer.Variable): Batch of padded target features. (B, Lmax, odim)
      calculate_attentions (bool): If true, return value is the output of encoder.
  
  Returns:
      float: Training loss.
      float (optional): Training loss for ctc.
      float (optional): Training loss for attention.
      float (optional): Accuracy.
      chainer.Variable (Optional): Output of the encoder.
docstr_tok: ["E2E","forward","propagation",".","Args",":","xs","(","chainer.Variable",")",":","Batch","of","padded","character","ids",".","(","B",",","Tmax",")","ilens","(","chainer.Variable",")",":","Batch","of","length","of","each","input","batch",".","(","B",",",")","ys","(","chainer.Variable",")",":","Batch","of","padded","target","features",".","(","B",",","Lmax",",","odim",")","calculate_attentions","(","bool",")",":","If","true",",","return","value","is","the","output","of","encoder",".","Returns",":","float",":","Training","loss",".","float","(","optional",")",":","Training","loss","for","ctc",".","float","(","optional",")",":","Training","loss","for","attention",".","float","(","optional",")",":","Accuracy",".","chainer.Variable","(","Optional",")",":","Output","of","the","encoder","."]
code: def forward(self, xs, ilens, ys_pad, calculate_attentions=False):
      """E2E forward propagation.
  
      Args:
          xs (chainer.Variable): Batch of padded character ids. (B, Tmax)
          ilens (chainer.Variable): Batch of length of each input batch. (B,)
          ys (chainer.Variable): Batch of padded target features. (B, Lmax, odim)
          calculate_attentions (bool): If true, return value is the output of encoder.
  
      Returns:
          float: Training loss.
          float (optional): Training loss for ctc.
          float (optional): Training loss for attention.
          float (optional): Accuracy.
          chainer.Variable (Optional): Output of the encoder.
  
      """
      alpha = self.mtlalpha
  
      # 1. Encoder
      xs, x_mask, ilens = self.encoder(xs, ilens)
  
      # 2. CTC loss
      cer_ctc = None
      if alpha == 0.0:
          loss_ctc = None
      else:
          _ys = [y.astype(np.int32) for y in ys_pad]
          loss_ctc = self.ctc(xs, _ys)
          if self.error_calculator is not None:
              with chainer.no_backprop_mode():
                  ys_hat = chainer.backends.cuda.to_cpu(
                      self.ctc.argmax(xs).data
                  )
              cer_ctc = self.error_calculator(
                  ys_hat, ys_pad, is_ctc=True
              )
  
      # 3. Decoder
      if calculate_attentions:
          self.calculate_attentions(xs, x_mask, ys_pad)
      ys = self.decoder(ys_pad, xs, x_mask)
  
      # 4. Attention Loss
      cer, wer = None, None
      if alpha == 1:
          loss_att = None
          acc = None
      else:
          # Make target
          eos = np.array([self.eos], "i")
          with chainer.no_backprop_mode():
              ys_pad_out = [
                  np.concatenate([y, eos], axis=0) for y in ys_pad
              ]
              ys_pad_out = F.pad_sequence(ys_pad_out, padding=-1).data
              ys_pad_out = self.xp.array(ys_pad_out)
  
          loss_att = self.criterion(ys, ys_pad_out)
          acc = F.accuracy(
              ys.reshape(-1, self.odim),
              ys_pad_out.reshape(-1),
              ignore_label=-1,
          )
          if (not chainer.config.train) and (
              self.error_calculator is not None
          ):
              cer, wer = self.error_calculator(ys, ys_pad)
  
      if alpha == 0.0:
          self.loss = loss_att
          loss_att_data = loss_att.data
          loss_ctc_data = None
      elif alpha == 1.0:
          self.loss = loss_ctc
          loss_att_data = None
          loss_ctc_data = loss_ctc.data
      else:
          self.loss = alpha * loss_ctc + (1 - alpha) * loss_att
          loss_att_data = loss_att.data
          loss_ctc_data = loss_ctc.data
      loss_data = self.loss.data
  
      if not math.isnan(loss_data):
          reporter.report({"loss_ctc": loss_ctc_data}, self)
          reporter.report({"loss_att": loss_att_data}, self)
          reporter.report({"acc": acc}, self)
  
          reporter.report({"cer_ctc": cer_ctc}, self)
          reporter.report({"cer": cer}, self)
          reporter.report({"wer": wer}, self)
  
          logging.info("mtl loss:" + str(loss_data))
          reporter.report({"loss": loss_data}, self)
      else:
          logging.warning("loss (=%f) is not correct", loss_data)
  
      if self.flag_return:
          loss_ctc = None
          return self.loss, loss_ctc, loss_att, acc
      else:
          return self.loss
  
imports: import logging
  import math
  from argparse import Namespace
  from distutils.util import strtobool
  import chainer
  import chainer.functions
  import numpy
  from chainer import reporter
  from espnet.nets.chainer_backend.asr_interface import ChainerASRInterface
  from espnet.nets.chainer_backend.transformer import ctc
  from espnet.nets.chainer_backend.transformer.attention import MultiHeadAttention
  from espnet.nets.chainer_backend.transformer.decoder import Decoder
  from espnet.nets.chainer_backend.transformer.encoder import Encoder
  from espnet.nets.chainer_backend.transformer.label_smoothing_loss import LabelSmoothingLoss
  from espnet.nets.chainer_backend.transformer.training import CustomConverter, CustomParallelUpdater, CustomUpdater
  from espnet.nets.ctc_prefix_score import CTCPrefixScore
  from espnet.nets.e2e_asr_common import ErrorCalculator, end_detect
  from espnet.nets.pytorch_backend.nets_utils import get_subsample
  from espnet.nets.pytorch_backend.transformer.plot import PlotAttentionReport
label_desc: Use image node_id 5 for calling the E2E obj's underlying member method code with example usage: obj.forward(xs, ilens, ys_pad, calculate_attentions) and returns: self,  loss_ctc,  loss_att,  acc, self