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: Construct an E2E object.
  
  :param int idim: dimension of inputs
  :param int odim: dimension of outputs
  :param Namespace args: argument Namespace containing options
code: def __init__(self, idim, odim, args):
      """Construct an E2E object.
  
      :param int idim: dimension of inputs
      :param int odim: dimension of outputs
      :param Namespace args: argument Namespace containing options
      """
      super(E2E, self).__init__()
      torch.nn.Module.__init__(self)
  
      # fill missing arguments for compatibility
      args = fill_missing_args(args, self.add_arguments)
  
      self.asr_weight = args.asr_weight
      self.mt_weight = args.mt_weight
      self.mtlalpha = args.mtlalpha
      assert (
          0.0 <= self.asr_weight < 1.0
      ), "asr_weight should be [0.0, 1.0)"
      assert (
          0.0 <= self.mt_weight < 1.0
      ), "mt_weight should be [0.0, 1.0)"
      assert (
          0.0 <= self.mtlalpha <= 1.0
      ), "mtlalpha should be [0.0, 1.0]"
      self.etype = args.etype
      self.verbose = args.verbose
      # NOTE: for self.build method
      args.char_list = getattr(args, "char_list", None)
      self.char_list = args.char_list
      self.outdir = args.outdir
      self.space = args.sym_space
      self.blank = args.sym_blank
      self.reporter = Reporter()
  
      # below means the last number becomes eos/sos ID
      # note that sos/eos IDs are identical
      self.sos = odim - 1
      self.eos = odim - 1
      self.pad = 0
      # NOTE: we reserve index:0 for <pad> although this is reserved for a blank class
      # in ASR. However, blank labels are not used in MT.
      # To keep the vocabulary size,
      # we use index:0 for padding instead of adding one more class.
  
      # subsample info
      self.subsample = get_subsample(args, mode="st", arch="rnn")
  
      # label smoothing info
      if args.lsm_type and os.path.isfile(args.train_json):
          logging.info("Use label smoothing with " + args.lsm_type)
          labeldist = label_smoothing_dist(
              odim, args.lsm_type, transcript=args.train_json
          )
      else:
          labeldist = None
  
      # multilingual related
      self.multilingual = getattr(args, "multilingual", False)
      self.replace_sos = getattr(args, "replace_sos", False)
  
      # encoder
      self.enc = encoder_for(args, idim, self.subsample)
      # attention (ST)
      self.att = att_for(args)
      # decoder (ST)
      self.dec = decoder_for(
          args, odim, self.sos, self.eos, self.att, labeldist
      )
  
      # submodule for ASR task
      self.ctc = None
      self.att_asr = None
      self.dec_asr = None
      if self.asr_weight > 0:
          if self.mtlalpha > 0.0:
              self.ctc = CTC(
                  odim,
                  args.eprojs,
                  args.dropout_rate,
                  ctc_type=args.ctc_type,
                  reduce=True,
              )
          if self.mtlalpha < 1.0:
              # attention (asr)
              self.att_asr = att_for(args)
              # decoder (asr)
              args_asr = copy.deepcopy(args)
              args_asr.atype = (
                  "location"  # TODO(hirofumi0810): make this option
              )
              self.dec_asr = decoder_for(
                  args_asr,
                  odim,
                  self.sos,
                  self.eos,
                  self.att_asr,
                  labeldist,
              )
  
      # submodule for MT task
      if self.mt_weight > 0:
          self.embed_mt = torch.nn.Embedding(
              odim, args.eunits, padding_idx=self.pad
          )
          self.dropout_mt = torch.nn.Dropout(p=args.dropout_rate)
          self.enc_mt = encoder_for(
              args,
              args.eunits,
              subsample=np.ones(args.elayers + 1, dtype=np.int64),
          )
  
      # weight initialization
      self.init_like_chainer()
  
      # options for beam search
      if self.asr_weight > 0 and args.report_cer or args.report_wer:
          recog_args = {
              "beam_size": args.beam_size,
              "penalty": args.penalty,
              "ctc_weight": args.ctc_weight,
              "maxlenratio": args.maxlenratio,
              "minlenratio": args.minlenratio,
              "lm_weight": args.lm_weight,
              "rnnlm": args.rnnlm,
              "nbest": args.nbest,
              "space": args.sym_space,
              "blank": args.sym_blank,
              "tgt_lang": False,
          }
  
          self.recog_args = argparse.Namespace(**recog_args)
          self.report_cer = args.report_cer
          self.report_wer = args.report_wer
      else:
          self.report_cer = False
          self.report_wer = False
      if args.report_bleu:
          trans_args = {
              "beam_size": args.beam_size,
              "penalty": args.penalty,
              "ctc_weight": 0,
              "maxlenratio": args.maxlenratio,
              "minlenratio": args.minlenratio,
              "lm_weight": args.lm_weight,
              "rnnlm": args.rnnlm,
              "nbest": args.nbest,
              "space": args.sym_space,
              "blank": args.sym_blank,
              "tgt_lang": False,
          }
  
          self.trans_args = argparse.Namespace(**trans_args)
          self.report_bleu = args.report_bleu
      else:
          self.report_bleu = False
      self.rnnlm = None
  
      self.logzero = -10000000000.0
      self.loss = None
      self.acc = None
  
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 6 to create a new E2E object from inherited base classes: STInterface, torch.nn with example: obj = E2E(idim, odim, args)