code: def build_dataset(
      cfg,
      trainer,
      data_prefix,
      data_impl,
      num_samples,
      seq_length,
      seed,
      skip_warmup,
      tokenizer,
      name,
  ):
      def _build_dataset(current_data_prefix, current_num_samples):
          delay_data_mmap = cfg.data.get("delay_data_mmap", False)
          indexed_dataset = get_indexed_dataset_(
              current_data_prefix,
              data_impl,
              skip_warmup,
              delay_data_mmap,
          )
          total_num_of_documents = indexed_dataset.sizes.shape[0]
          # Print stats about the splits.
          logging.info(" > dataset split:")
          logging.info(
              "     Total {} documents is : {} ".format(
                  name, total_num_of_documents
              )
          )
          drop_last = True
          if name == "valid":
              drop_last = cfg.data.get("validation_drop_last", True)
          dataset = GPTDataset(
              cfg,
              trainer,
              tokenizer,
              name,
              current_data_prefix,
              np.arange(
                  start=0,
                  stop=total_num_of_documents,
                  step=1,
                  dtype=np.int32,
              ),
              indexed_dataset,
              current_num_samples,
              seq_length,
              seed,
              drop_last=drop_last,
          )
          return dataset
  
      if len(data_prefix) == 1:
          return _build_dataset(data_prefix[0], num_samples)
  
      else:
          output = get_datasets_weights_and_num_samples(
              data_prefix, num_samples
          )
          prefixes, weights, datasets_num_samples = output
          datasets = []
          for i in range(len(prefixes)):
              dataset = _build_dataset(
                  prefixes[i], datasets_num_samples[i]
              )
              datasets.append(dataset)
          return BlendableDataset(datasets, weights, num_samples)
  
imports: import os
  import time
  import numpy
  import torch
  from omegaconf.dictconfig import DictConfig
  from nemo.collections.nlp.data.language_modeling.megatron.base_dataset_utils import get_datasets_weights_and_num_samples, get_train_valid_test_split_
  from nemo.collections.nlp.data.language_modeling.megatron.blendable_dataset import BlendableDataset
  from nemo.collections.nlp.data.language_modeling.megatron.indexed_dataset import deallocate_indexed_dataset_memory
  from nemo.collections.nlp.data.language_modeling.megatron.indexed_dataset import make_dataset
  from nemo.core import Dataset
  from nemo.utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: build_dataset(cfg, trainer, data_prefix, data_impl, num_samples, seq_length, seed, skip_warmup, tokenizer, name) and returns: dataset, _build_dataset, BlendableDataset