class_docstr: Megatron T5 pretraining
class_docstr_tok: ["Megatron","T5","pretraining"]
code: def build_train_valid_test_datasets(self):
      # Override limit_val_batches to be a multiple of num microbatches to prevent val_step from exiting in between a step
      self._reconfigure_val_batches()
      logging.info(f"Building {self.model_name} datasets.")
      if self.trainer.limit_val_batches > 1.0 and isinstance(
          self.trainer.limit_val_batches, float
      ):
          raise ValueError(
              "limit_val_batches must be an integer or float less than or equal to 1.0."
          )
      global_batch_size = self._cfg.global_batch_size
      eval_iters = (
          self.trainer.max_steps // self.trainer.val_check_interval + 1
      ) * self.trainer.limit_val_batches
      test_iters = self.trainer.limit_test_batches
      train_valid_test_num_samples = [
          self.trainer.max_steps * global_batch_size,
          eval_iters * global_batch_size,
          test_iters * global_batch_size,
      ]
  
      if self.trainer.limit_val_batches <= 1.0 and isinstance(
          self.trainer.limit_val_batches, float
      ):
          train_valid_test_num_samples[
              1
          ] = 1  # This is to make sure we only have one epoch on every validation iteration
  
      (
          self._train_ds,
          self._validation_ds,
          self._test_ds,
      ) = build_train_valid_test_datasets(
          cfg=self._cfg,
          trainer=self.trainer,
          tokenizer=self.tokenizer,
          data_prefix=self._cfg.data.data_prefix,
          data_impl=self._cfg.data.data_impl,
          splits_string=self._cfg.data.splits_string,
          train_valid_test_num_samples=train_valid_test_num_samples,
          max_seq_length=self._cfg.data.seq_length,
          masked_lm_prob=self._cfg.data.masked_lm_prob,
          short_seq_prob=self._cfg.data.short_seq_prob,
          seed=self._cfg.seed,
          skip_warmup=self._cfg.data.skip_warmup,
          dataset_type=self._cfg.data.get(
              "dataset_type", self.model_name.lower()
          ),
          max_ngram_size=self._cfg.data.get("max_ngram_size", 10),
          mean_ngram_size=self._cfg.data.get("mean_ngram_size", None),
          geometric_dist=self._cfg.data.get("geometric_dist", True),
          permutation=self._cfg.data.get("permutation", False),
          whole_word_masking=self._cfg.data.get(
              "whole_word_masking", True
          ),
          favor_long_ngrams=self._cfg.data.get(
              "favor_long_ngrams", False
          ),
          respect_document_boundaries=self._cfg.data.get(
              "respect_document_boundaries", True
          ),
          data_impl_kwargs=self._cfg.data.get("data_impl_kwargs", {}),
          # additional arguments from child classes
          **self._build_train_valid_test_datasets_kwargs,
      )
      logging.info(f"Length of train dataset: {len(self._train_ds)}")
      logging.info(f"Length of val dataset: {len(self._validation_ds)}")
      logging.info(f"Length of test dataset: {len(self._test_ds)}")
      logging.info(f"Finished building {self.model_name} datasets.")
      return self._train_ds, self._validation_ds, self._test_ds
  
imports: import enum
  import math
  from omegaconf.dictconfig import DictConfig
  from pytorch_lightning.trainer.trainer import Trainer
  from nemo.collections.nlp.data.language_modeling.megatron.dataset_utils import build_train_valid_test_datasets
  from nemo.collections.nlp.models.language_modeling.megatron_lm_encoder_decoder_model import MegatronLMEncoderDecoderModel
  from nemo.utils import logging
label_desc: Use image node_id 9 for calling the MegatronT5Model obj's underlying member method code with example usage: obj.build_train_valid_test_datasets() and returns: self,  self,  self