class_docstr: T0 (https://arxiv.org/abs/2110.08207) Model that Inherits from MegatronT5SFTModel and overrides the dataset building.
code: def _build_dataset(
      self, data_cfg, check_implict_grad_acc=False, is_train=True
  ):
      if (
          check_implict_grad_acc
          and data_cfg.global_batch_size
          > data_cfg.micro_batch_size
          * parallel_state.get_data_parallel_world_size()
      ):
          raise ValueError(
              f'You are trying to use "implicit gradient accumulation" of {data_cfg.global_batch_size // (data_cfg.micro_batch_size * parallel_state.get_data_parallel_world_size())} in your validation/test datasets. This is not supported. Please set global_batch_size equal to micro_batch_size * data_parallel_world_size.'
          )
      datasets = []
      # Determine if we are using a single dataset or a list of datasets.
      is_list_config = isinstance(data_cfg.file_names, ListConfig)
      if not is_list_config:
          raise ValueError(
              f"T0 train/validation datasets must be provided as a list of individual JSONL files."
          )
  
      if is_train:
          # Construct the data prefix list for `get_datasets_weights_and_num_samples()` that is of the format [weight1,file_name1,weight2,file_name2,...]
          if (
              data_cfg.concat_sampling_probabilities is None
              or not isinstance(
                  data_cfg.concat_sampling_probabilities, ListConfig
              )
          ):
              raise ValueError(
                  f"concat_sampling_probabilities must be a ListConfig with the same number of files in file_names. Found: {data_cfg.concat_sampling_probabilities}"
              )
  
          if len(
              data_cfg.get("concat_sampling_probabilities", None)
          ) != len(data_cfg.file_names):
              raise ValueError(
                  f"concat_sampling_probabilities must be of the same size as file_names. Provided size {len(data_cfg.concat_sampling_probabilities)}, number of datasets {len(data_cfg.file_names)}"
              )
  
          data_prefix = []
          for weight, prefix in zip(
              data_cfg.concat_sampling_probabilities,
              data_cfg.file_names,
          ):
              data_prefix.append(weight)
              data_prefix.append(prefix)
  
          if (
              self.trainer.max_steps is None
              or self.trainer.max_steps <= 0
          ):
              raise ValueError(
                  f"Trainer max_steps must be set to a positive integer. Found {self.trainer.max_steps}"
              )
          num_train_samples = [
              self.trainer.max_steps * self.cfg.global_batch_size
          ]
          (
              _,
              _,
              num_train_samples_per_dataset,
          ) = get_datasets_weights_and_num_samples(
              data_prefix, num_train_samples
          )
          num_train_samples_after_blend = sum(
              [x[0] for x in num_train_samples_per_dataset]
          )
      else:
          num_train_samples_per_dataset = [[None]] * len(
              data_cfg.file_names
          )
  
      for file_path, num_samples in zip(
          data_cfg.file_names, num_train_samples_per_dataset
      ):
          dataset = T0Dataset(
              file_path=file_path,
              tokenizer=self.tokenizer,
              max_src_seq_length=data_cfg.max_src_seq_length,
              max_tgt_seq_length=data_cfg.max_tgt_seq_length,
              add_bos_to_input=data_cfg.get("add_bos_to_input", False),
              add_eos_to_input=data_cfg.get("add_eos_to_input", False),
              replace_bos_with_pad=data_cfg.get(
                  "replace_bos_with_pad", False
              ),
              max_num_samples=num_samples[0],
              seed=data_cfg.get("seed", 1234),
          )
          datasets.append(dataset)
  
      if is_train:
          dataset = BlendableDataset(
              datasets=datasets,
              weights=data_cfg.concat_sampling_probabilities,
              size=num_train_samples_after_blend,
          )
          return dataset
      else:
          return datasets
  
imports: import torch
  from omegaconf import DictConfig, ListConfig
  from pytorch_lightning.trainer.trainer import Trainer
  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.t0_dataset import T0Dataset
  from nemo.collections.nlp.models.language_modeling.megatron_t5_sft_model import MegatronT5SFTModel
  from nemo.utils import AppState, logging
label_desc: Use image node_id 3 for calling the MegatronT0Model obj's underlying member method code with example usage: obj._build_dataset(data_cfg, check_implict_grad_acc, is_train) and returns: dataset, datasets