class_docstr: Encoder-Decoder model
code: def __init__(
      self,
      vocab_size: int,
      token_list: Union[Tuple[str, ...], List[str]],
      frontend: Optional[AbsFrontend],
      preencoder: Optional[AbsPreEncoder],
      encoder: AbsEncoder,
      postencoder: Optional[AbsPostEncoder],
      decoder: AbsDecoder,
      src_vocab_size: int = 0,
      src_token_list: Union[Tuple[str, ...], List[str]] = [],
      ignore_id: int = -1,
      lsm_weight: float = 0.0,
      length_normalized_loss: bool = False,
      report_bleu: bool = True,
      sym_space: str = "<space>",
      sym_blank: str = "<blank>",
      extract_feats_in_collect_stats: bool = True,
      share_decoder_input_output_embed: bool = False,
      share_encoder_decoder_input_embed: bool = False,
  ):
      assert check_argument_types()
  
      super().__init__()
      # note that eos is the same as sos (equivalent ID)
      self.sos = vocab_size - 1
      self.eos = vocab_size - 1
      self.src_sos = src_vocab_size - 1 if src_vocab_size else None
      self.src_eos = src_vocab_size - 1 if src_vocab_size else None
      self.vocab_size = vocab_size
      self.src_vocab_size = src_vocab_size
      self.ignore_id = ignore_id
      self.token_list = token_list.copy()
  
      if share_decoder_input_output_embed:
          if decoder.output_layer is not None:
              decoder.output_layer.weight = decoder.embed[0].weight
              logging.info(
                  "Decoder input embedding and output linear layer are shared"
              )
          else:
              logging.warning(
                  "Decoder has no output layer, so it cannot be shared "
                  "with input embedding"
              )
  
      if share_encoder_decoder_input_embed:
          if src_vocab_size == vocab_size:
              frontend.embed[0].weight = decoder.embed[0].weight
              logging.info(
                  "Encoder and decoder input embeddings are shared"
              )
          else:
              logging.warning(
                  f"src_vocab_size ({src_vocab_size}) does not equal tgt_vocab_size"
                  f" ({vocab_size}), so the encoder and decoder input embeddings "
                  "cannot be shared"
              )
  
      self.frontend = frontend
      self.preencoder = preencoder
      self.postencoder = postencoder
      self.encoder = encoder
      self.decoder = decoder
  
      self.criterion_mt = LabelSmoothingLoss(
          size=vocab_size,
          padding_idx=ignore_id,
          smoothing=lsm_weight,
          normalize_length=length_normalized_loss,
      )
  
      # MT error calculator
      if report_bleu:
          self.mt_error_calculator = MTErrorCalculator(
              token_list, sym_space, sym_blank, report_bleu
          )
      else:
          self.mt_error_calculator = None
  
      self.extract_feats_in_collect_stats = (
          extract_feats_in_collect_stats
      )
  
imports: import logging
  from contextlib import contextmanager
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from packaging.version import parse
  from typeguard import check_argument_types
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.frontend.abs_frontend import AbsFrontend
  from espnet2.asr.postencoder.abs_postencoder import AbsPostEncoder
  from espnet2.asr.preencoder.abs_preencoder import AbsPreEncoder
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
  from espnet.nets.e2e_mt_common import ErrorCalculator
  from espnet.nets.pytorch_backend.nets_utils import th_accuracy
  from espnet.nets.pytorch_backend.transformer.add_sos_eos import add_sos_eos
  from espnet.nets.pytorch_backend.transformer.label_smoothing_loss import LabelSmoothingLoss
label_desc: Use image node_id 1 to create a new ESPnetMTModel object from inherited base classes: AbsESPnetModel with example: obj = ESPnetMTModel(vocab_size, token_list, frontend, preencoder, encoder, postencoder, decoder, src_vocab_size, src_token_list, ignore_id, lsm_weight, length_normalized_loss, report_bleu, sym_space, sym_blank, extract_feats_in_collect_stats, share_decoder_input_output_embed, share_encoder_decoder_input_embed)