class_docstr: Megatron NMT training
class_docstr_tok: ["Megatron","NMT","training"]
docstr: Calls the translate() method with the option of running ITN (inverse text-normalization) on the input and TN (text-normalization) on the output.
  Pipeline : ITN -> translate -> TN
  NOTE: ITN and TN objects must be initialized with the right languages.
  Args:
      text: list of strings to translate
      source_lang: if not "ignore", corresponding MosesTokenizer and MosesPunctNormalizer will be run
      target_lang: if not "ignore", corresponding MosesDecokenizer will be run
      return_beam_scores: if True, returns a list of translations and their corresponding beam scores.
      log_timing: if True, prints timing information.
      inverse_normalizer: instance of nemo_text_processing.inverse_text_normalization.inverse_normalize.InverseNormalizer
      normalizer: instance of nemo_text_processing.text_normalization.normalize.Normalizer
  Returns:
      list of translated strings
code: def itn_translate_tn(
      self,
      text: List[str],
      source_lang: str = None,
      target_lang: str = None,
      return_beam_scores: bool = False,
      log_timing: bool = False,
      inverse_normalizer=None,
      normalizer=None,
      prepend_tgt_lang_id: bool = False,
  ) -> List[str]:
      """
      Calls the translate() method with the option of running ITN (inverse text-normalization) on the input and TN (text-normalization) on the output.
      Pipeline : ITN -> translate -> TN
      NOTE: ITN and TN objects must be initialized with the right languages.
      Args:
          text: list of strings to translate
          source_lang: if not "ignore", corresponding MosesTokenizer and MosesPunctNormalizer will be run
          target_lang: if not "ignore", corresponding MosesDecokenizer will be run
          return_beam_scores: if True, returns a list of translations and their corresponding beam scores.
          log_timing: if True, prints timing information.
          inverse_normalizer: instance of nemo_text_processing.inverse_text_normalization.inverse_normalize.InverseNormalizer
          normalizer: instance of nemo_text_processing.text_normalization.normalize.Normalizer
      Returns:
          list of translated strings
      """
      if inverse_normalizer is not None:
          text = [
              inverse_normalizer.normalize(example) for example in text
          ]
      translations = self.translate(
          text,
          source_lang,
          target_lang,
          return_beam_scores,
          log_timing,
          prepend_tgt_lang_id,
      )
      if normalizer is not None:
          translations = [
              normalizer.normalize(example) for example in translations
          ]
      return translations
  
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 28 for calling the MegatronNMTModel obj's underlying member method code with example usage: obj.itn_translate_tn(text, source_lang, target_lang, return_beam_scores, log_timing, inverse_normalizer, normalizer, prepend_tgt_lang_id) and returns: translations