code: def build_dataset(
      cfg,
      trainer,
      data_prefix,
      data_impl,
      num_samples,
      max_seq_length,
      masked_lm_prob,
      short_seq_prob,
      seed,
      skip_warmup,
      binary_head,
      max_seq_length_dec,
      name,
      dataset_type,
      tokenizer,
      max_ngram_size,
      mean_ngram_size,
      geometric_dist,
      permutation,
      whole_word_masking,
      favor_long_ngrams,
      delete_mask_prob,
      respect_document_boundaries,
      data_impl_kwargs,
  ):
      def _build_dataset(current_data_prefix, current_num_samples):
          indexed_dataset = get_indexed_dataset_(
              current_data_prefix,
              data_impl,
              skip_warmup,
              data_impl_kwargs=data_impl_kwargs,
          )
          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
              )
          )
          if hasattr(indexed_dataset, "get_doc_idx"):
              doc_idx_ptr = indexed_dataset.get_doc_idx()
              indexed_dataset.set_doc_idx(
                  doc_idx_ptr[0:total_num_of_documents]
              )
  
          kwargs = dict(
              name=name,
              data_prefix=current_data_prefix,
              num_epochs=None,
              max_num_samples=int(current_num_samples),
              max_seq_length=max_seq_length,
              seed=seed,
          )
  
          dataset = get_dataset(
              indexed_dataset,
              0,
              total_num_of_documents,
              cfg,
              trainer,
              current_num_samples,
              masked_lm_prob,
              short_seq_prob,
              binary_head,
              max_seq_length_dec,
              dataset_type,
              tokenizer,
              max_ngram_size,
              mean_ngram_size,
              geometric_dist,
              permutation,
              whole_word_masking,
              favor_long_ngrams,
              delete_mask_prob,
              respect_document_boundaries,
              **kwargs,
          )
  
          # Set the original pointer so dataset remains the main dataset.
          if hasattr(indexed_dataset, "set_doc_idx"):
              indexed_dataset.set_doc_idx(doc_idx_ptr)
          # Checks.
          assert indexed_dataset.doc_idx[0] == 0
          assert indexed_dataset.doc_idx.shape[0] == (
              total_num_of_documents + 1
          )
          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 collections
  import os
  import subprocess
  import time
  from typing import Any
  import numpy
  import torch
  from omegaconf import OmegaConf
  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.collections.nlp.data.language_modeling.megatron.indexed_dataset import make_indexed_dataset_compatibility
  from nemo.collections.nlp.data.language_modeling.megatron.length_distribution_type import LengthDistribution
  from nemo.collections.nlp.data.language_modeling.megatron.lm_adapted_t5_dataset import T5LMAdaptedDataset
  from nemo.utils import logging
  from nemo.utils.get_rank import is_global_rank_zero
label_desc: Use image node_id 11 for calling a global function with example usage: build_dataset(cfg, trainer, data_prefix, data_impl, num_samples, max_seq_length, masked_lm_prob, short_seq_prob, seed, skip_warmup, binary_head, max_seq_length_dec, name, dataset_type, tokenizer, max_ngram_size, mean_ngram_size, geometric_dist, permutation, whole_word_masking, favor_long_ngrams, delete_mask_prob, respect_document_boundaries, data_impl_kwargs) and returns: dataset, _build_dataset, BlendableDataset