class_docstr: 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, ignore_id=-1):
      """Construct an E2E object.
  
      :param int idim: dimension of inputs
      :param int odim: dimension of outputs
      :param Namespace args: argument Namespace containing options
      """
      torch.nn.Module.__init__(self)
  
      # fill missing arguments for compatibility
      args = fill_missing_args(args, self.add_arguments)
  
      if args.transformer_attn_dropout_rate is None:
          args.transformer_attn_dropout_rate = args.dropout_rate
      self.encoder = Encoder(
          idim=idim,
          selfattention_layer_type=args.transformer_encoder_selfattn_layer_type,
          attention_dim=args.adim,
          attention_heads=args.aheads,
          conv_wshare=args.wshare,
          conv_kernel_length=args.ldconv_encoder_kernel_length,
          conv_usebias=args.ldconv_usebias,
          linear_units=args.eunits,
          num_blocks=args.elayers,
          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,
      )
      self.decoder = Decoder(
          odim=odim,
          selfattention_layer_type=args.transformer_decoder_selfattn_layer_type,
          attention_dim=args.adim,
          attention_heads=args.aheads,
          conv_wshare=args.wshare,
          conv_kernel_length=args.ldconv_decoder_kernel_length,
          conv_usebias=args.ldconv_usebias,
          linear_units=args.dunits,
          num_blocks=args.dlayers,
          dropout_rate=args.dropout_rate,
          positional_dropout_rate=args.dropout_rate,
          self_attention_dropout_rate=args.transformer_attn_dropout_rate,
          src_attention_dropout_rate=args.transformer_attn_dropout_rate,
      )
      self.pad = 0  # use <blank> for padding
      self.sos = odim - 1
      self.eos = odim - 1
      self.odim = odim
      self.ignore_id = ignore_id
      self.subsample = get_subsample(
          args, mode="st", arch="transformer"
      )
      self.reporter = Reporter()
  
      self.criterion = LabelSmoothingLoss(
          self.odim,
          self.ignore_id,
          args.lsm_weight,
          args.transformer_length_normalized_loss,
      )
      # submodule for ASR task
      self.mtlalpha = args.mtlalpha
      self.asr_weight = args.asr_weight
      if self.asr_weight > 0 and args.mtlalpha < 1:
          self.decoder_asr = Decoder(
              odim=odim,
              attention_dim=args.adim,
              attention_heads=args.aheads,
              linear_units=args.dunits,
              num_blocks=args.dlayers,
              dropout_rate=args.dropout_rate,
              positional_dropout_rate=args.dropout_rate,
              self_attention_dropout_rate=args.transformer_attn_dropout_rate,
              src_attention_dropout_rate=args.transformer_attn_dropout_rate,
          )
  
      # submodule for MT task
      self.mt_weight = args.mt_weight
      if self.mt_weight > 0:
          self.encoder_mt = Encoder(
              idim=odim,
              attention_dim=args.adim,
              attention_heads=args.aheads,
              linear_units=args.dunits,
              num_blocks=args.dlayers,
              input_layer="embed",
              dropout_rate=args.dropout_rate,
              positional_dropout_rate=args.dropout_rate,
              attention_dropout_rate=args.transformer_attn_dropout_rate,
              padding_idx=0,
          )
      self.reset_parameters(
          args
      )  # NOTE: place after the submodule initialization
      self.adim = args.adim  # used for CTC (equal to d_model)
      if self.asr_weight > 0 and args.mtlalpha > 0.0:
          self.ctc = CTC(
              odim,
              args.adim,
              args.dropout_rate,
              ctc_type=args.ctc_type,
              reduce=True,
          )
      else:
          self.ctc = None
  
      # translation error calculator
      self.error_calculator = MTErrorCalculator(
          args.char_list,
          args.sym_space,
          args.sym_blank,
          args.report_bleu,
      )
  
      # recognition error calculator
      self.error_calculator_asr = ASRErrorCalculator(
          args.char_list,
          args.sym_space,
          args.sym_blank,
          args.report_cer,
          args.report_wer,
      )
      self.rnnlm = None
  
      # multilingual E2E-ST related
      self.multilingual = getattr(args, "multilingual", False)
      self.replace_sos = getattr(args, "replace_sos", False)
  
imports: import logging
  import math
  from argparse import Namespace
  import numpy
  import torch
  from espnet.nets.e2e_asr_common import ErrorCalculator
  from espnet.nets.e2e_asr_common import end_detect
  from espnet.nets.e2e_mt_common import ErrorCalculator
  from espnet.nets.pytorch_backend.ctc import CTC
  from espnet.nets.pytorch_backend.e2e_asr import CTC_LOSS_THRESHOLD
  from espnet.nets.pytorch_backend.e2e_st import Reporter
  from espnet.nets.pytorch_backend.nets_utils import get_subsample, make_non_pad_mask, pad_list, th_accuracy
  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.nets.st_interface import STInterface
  from espnet.utils.fill_missing_args import fill_missing_args
label_desc: Use image node_id 4 to create a new E2E object from inherited base classes: STInterface, torch.nn with example: obj = E2E(idim, odim, args, ignore_id)