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: Initialize the transformer.
docstr_tok: ["Initialize","the","transformer","."]
code: def __init__(self, idim, odim, args, ignore_id=-1, flag_return=True):
      """Initialize the transformer."""
      chainer.Chain.__init__(self)
      self.mtlalpha = args.mtlalpha
      assert 0 <= self.mtlalpha <= 1, "mtlalpha must be [0,1]"
      if args.transformer_attn_dropout_rate is None:
          args.transformer_attn_dropout_rate = args.dropout_rate
      self.use_label_smoothing = False
      self.char_list = args.char_list
      self.space = args.sym_space
      self.blank = args.sym_blank
      self.scale_emb = args.adim**0.5
      self.sos = odim - 1
      self.eos = odim - 1
      self.subsample = get_subsample(
          args, mode="asr", arch="transformer"
      )
      self.ignore_id = ignore_id
      self.reset_parameters(args)
      with self.init_scope():
          self.encoder = Encoder(
              idim=idim,
              attention_dim=args.adim,
              attention_heads=args.aheads,
              linear_units=args.eunits,
              input_layer=args.transformer_input_layer,
              dropout_rate=args.dropout_rate,
              positional_dropout_rate=args.dropout_rate,
              attention_dropout_rate=args.transformer_attn_dropout_rate,
              initialW=self.initialW,
              initial_bias=self.initialB,
          )
          self.decoder = Decoder(
              odim,
              args,
              initialW=self.initialW,
              initial_bias=self.initialB,
          )
          self.criterion = LabelSmoothingLoss(
              args.lsm_weight,
              len(args.char_list),
              args.transformer_length_normalized_loss,
          )
          if args.mtlalpha > 0.0:
              if args.ctc_type == "builtin":
                  logging.info("Using chainer CTC implementation")
                  self.ctc = ctc.CTC(odim, args.adim, args.dropout_rate)
              else:
                  raise ValueError(
                      'ctc_type must be "builtin": {}'.format(
                          args.ctc_type
                      )
                  )
          else:
              self.ctc = None
      self.dims = args.adim
      self.odim = odim
      self.flag_return = flag_return
      if args.report_cer or args.report_wer:
          self.error_calculator = ErrorCalculator(
              args.char_list,
              args.sym_space,
              args.sym_blank,
              args.report_cer,
              args.report_wer,
          )
      else:
          self.error_calculator = None
      if "Namespace" in str(type(args)):
          self.verbose = 0 if "verbose" not in args else args.verbose
      else:
          self.verbose = 0 if args.verbose is None else args.verbose
  
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 3 to create a new E2E object from inherited base classes: ChainerASRInterface with example: obj = E2E(idim, odim, args, ignore_id, flag_return)