class_docstr: Megatron NMT training
class_docstr_tok: ["Megatron","NMT","training"]
code: def __init__(self, cfg: DictConfig, trainer: Trainer):
      # All of the lines below need to be set when the parent class calls self._build_tokenizer()
      self.encoder_tokenizer_library = cfg.encoder_tokenizer.get(
          "library", "yttm"
      )
      self.decoder_tokenizer_library = cfg.decoder_tokenizer.get(
          "library", "yttm"
      )
      self.multilingual_lang_tokens = {}
      self.src_language = cfg.get("src_language", None)
      self.tgt_language = cfg.get("tgt_language", None)
  
      self.multilingual = cfg.get("multilingual", False)
      self.multilingual_ids = []
  
      self.validate_input_ids = cfg.get("validate_input_ids", True)
      self.objective = cfg.train_ds.get("objective", "nmt")
  
      if self.objective == "nmt-xlm":
          if not self.multilingual:
              raise ValueError(
                  "nmt-xlm objective requires model.multilingual=True"
              )
  
      if self.multilingual:
          self.multilingual_type = (
              self._determine_multilingual_training_type()
          )
          self._setup_multilingual_special_tokens()
      else:
          self.multilingual_type = None
  
      super().__init__(cfg, trainer=trainer)
  
imports: import enum
  import itertools
  import random
  from typing import List, Optional
  import numpy
  import torch
  from omegaconf.dictconfig import DictConfig
  from omegaconf.listconfig import ListConfig
  from pytorch_lightning.trainer.trainer import Trainer
  from sacrebleu import corpus_bleu
  from nemo.collections.nlp.data.common.sequence_to_sequence_dataset import BinarizedMemmapSequenceToSequenceDataset, TextMemmapSequenceToSequenceDataset
  from nemo.collections.nlp.data.language_modeling.megatron.base_dataset_utils import get_datasets_weights_and_num_samples
  from nemo.collections.nlp.data.language_modeling.megatron.blendable_dataset import BlendableDataset
  from nemo.collections.nlp.data.language_modeling.megatron.megatron_batch_samplers import MegatronPretrainingBatchSampler
  from nemo.collections.nlp.data.language_modeling.megatron.xlm_dataset import BinarizedMemmapCrossLingualMLMAndTranslationDataset, TextMemmapCrossLingualMLMAndTranslationDataset
  from nemo.collections.nlp.models.language_modeling.megatron_lm_encoder_decoder_model import MegatronLMEncoderDecoderModel
  from nemo.collections.nlp.models.language_modeling.megatron_t5_model import MegatronT5Model
  from nemo.collections.nlp.models.machine_translation.mt_enc_dec_model import MTEncDecModel
  from nemo.collections.nlp.modules.common.megatron.megatron_export import DecEmb, EncEmb, TokensHeadEmb
  from nemo.collections.nlp.modules.common.megatron.utils import get_iterator_k_split
  from nemo.collections.nlp.parts.nlp_overrides import GlobalBatchDataFetcher
  from nemo.collections.nlp.parts.utils_funcs import get_last_rank
  from nemo.core.classes import Exportable
  from nemo.utils import AppState, logging, timers
label_desc: Use image node_id 1 to create a new MegatronNMTModel object from inherited base classes: MegatronLMEncoderDecoderModel, Exportable with example: obj = MegatronNMTModel(cfg, trainer)