code: def get_dataset(
      indexed_dataset,
      start_index,
      end_index,
      cfg,
      trainer,
      num_samples,
      masked_lm_prob,
      short_seq_prob,
      binary_head,
      max_seq_length_dec,
      dataset_type="standard_bert",
      tokenizer=None,
      max_ngram_size=3,
      mean_ngram_size=None,
      geometric_dist=True,
      permutation=False,
      whole_word_masking=True,
      favor_long_ngrams=False,
      delete_mask_prob=0,  # This flag is used in BART only, and will not have effect on T5/BERT
      respect_document_boundaries=True,
      **kwargs,
  ):
      if dataset_type not in DSET_TYPES:
          raise ValueError("Invalid dataset_type: ", dataset_type)
  
      # from nemo.collections.nlp.data.language_modeling.megatron.ict_dataset import ICTDataset
      from nemo.collections.nlp.data.language_modeling.megatron.bart_dataset import (
          BARTDataset,
      )
      from nemo.collections.nlp.data.language_modeling.megatron.bert_dataset import (
          BertDataset,
      )
      from nemo.collections.nlp.data.language_modeling.megatron.length_distribution_type import (
          LengthDistribution,
      )
      from nemo.collections.nlp.data.language_modeling.megatron.t5_dataset import (
          T5Dataset,
      )
      from nemo.collections.nlp.data.language_modeling.megatron.ul2_dataset import (
          UL2Dataset,
      )
  
      if dataset_type == DSET_TYPE_ICT:
          raise NotImplementedError(
              "ICT dataset is not implemented yet."
          )
          """
          dataset = ICTDataset(
              block_dataset=indexed_dataset,
              title_dataset=title_dataset,
              query_in_block_prob=args.query_in_block_prob,
              use_one_sent_docs=args.use_one_sent_docs,
              binary_head=binary_head,
              **kwargs,
          )
          """
      elif dataset_type == DSET_TYPE_T5:
          assert (
              tokenizer is not None
          ), "Tokenizer is required for T5 dataset"
          logging.info("Instatiating T5 Dataset ...")
          documents = np.arange(
              start=start_index, stop=end_index, step=1, dtype=np.int32
          )
          dataset = T5Dataset(
              cfg=cfg,
              trainer=trainer,
              tokenizer=tokenizer,
              indexed_dataset=indexed_dataset,
              masked_lm_prob=masked_lm_prob,
              max_seq_length_dec=max_seq_length_dec,
              short_seq_prob=short_seq_prob,
              max_ngram_size=max_ngram_size,
              mean_ngram_size=mean_ngram_size,
              geometric_dist=geometric_dist,
              permutation=permutation,
              whole_word_masking=whole_word_masking,
              favor_long_ngrams=favor_long_ngrams,
              documents=documents,
              respect_document_boundaries=respect_document_boundaries,
              **kwargs,
          )
      elif dataset_type == DSET_TYPE_BERT:
          logging.info("Instatiating BERT Dataset ...")
          dataset = BertDataset(
              cfg=cfg,
              indexed_dataset=indexed_dataset,
              masked_lm_prob=masked_lm_prob,
              short_seq_prob=short_seq_prob,
              binary_head=binary_head,
              tokenizer=tokenizer,
              **kwargs,
          )
      elif dataset_type == DSET_TYPE_T5_LM:
          documents = np.arange(
              start=start_index, stop=end_index, step=1, dtype=np.int32
          )
          logging.info("Instatiating T5 Prefix-LM Dataset ...")
          dataset = T5LMAdaptedDataset(
              cfg=cfg,
              trainer=trainer,
              tokenizer=tokenizer,
              documents=documents,
              indexed_dataset=indexed_dataset,
              num_samples=num_samples,
              max_seq_length_encoder=kwargs["max_seq_length"],
              max_seq_length_decoder=max_seq_length_dec,
              **kwargs,
          )
      elif dataset_type == DSET_TYPE_BART:
          assert (
              tokenizer is not None
          ), "Tokenizer is required for BART dataset"
          documents = np.arange(
              start=start_index, stop=end_index, step=1, dtype=np.int32
          )
          logging.info("Instatiating BART Dataset ...")
          dataset = BARTDataset(
              cfg=cfg,
              trainer=trainer,
              tokenizer=tokenizer,
              indexed_dataset=indexed_dataset,
              masked_lm_prob=masked_lm_prob,
              short_seq_prob=short_seq_prob,
              max_ngram_size=max_ngram_size,
              mean_ngram_size=mean_ngram_size,
              geometric_dist=geometric_dist,
              permutation=permutation,
              whole_word_masking=whole_word_masking,
              favor_long_ngrams=favor_long_ngrams,
              delete_mask_prob=delete_mask_prob,
              documents=documents,
              respect_document_boundaries=respect_document_boundaries,
              **kwargs,
          )
      elif dataset_type == DSET_TYPE_UL2:
          assert (
              tokenizer is not None
          ), "Tokenizer is required for UL2 dataset"
          documents = np.arange(
              start=start_index, stop=end_index, step=1, dtype=np.int32
          )
          logging.info("Instatiating UL2 Dataset ...")
          extreme_ngram_span_length_distribution = cfg.data.get(
              "extreme_ngram_span_length_distribution",
              "truncated_normal",
          )
          ngram_span_length_distribution = cfg.data.get(
              "ngram_span_length_distribution", "geometric"
          )
          if (
              extreme_ngram_span_length_distribution
              == "truncated_normal"
          ):
              extreme_ngram_span_length_distribution = (
                  LengthDistribution.truncated_normal
              )
          elif extreme_ngram_span_length_distribution == "uniform":
              extreme_ngram_span_length_distribution = (
                  LengthDistribution.uniform
              )
          elif extreme_ngram_span_length_distribution == "geometric":
              extreme_ngram_span_length_distribution = (
                  LengthDistribution.geometric
              )
  
          if ngram_span_length_distribution == "truncated_normal":
              ngram_span_length_distribution = (
                  LengthDistribution.truncated_normal
              )
          elif ngram_span_length_distribution == "uniform":
              ngram_span_length_distribution = (
                  LengthDistribution.uniform
              )
          elif ngram_span_length_distribution == "geometric":
              ngram_span_length_distribution = (
                  LengthDistribution.geometric
              )
  
          dataset = UL2Dataset(
              cfg=cfg,
              trainer=trainer,
              tokenizer=tokenizer,
              indexed_dataset=indexed_dataset,
              masked_lm_prob=masked_lm_prob,
              max_seq_length_dec=max_seq_length_dec,
              short_seq_prob=short_seq_prob,
              max_ngram_size=max_ngram_size,
              mean_ngram_size=mean_ngram_size,
              ngram_span_length_distribution=ngram_span_length_distribution,
              extreme_ngram_span_length_distribution=extreme_ngram_span_length_distribution,
              permutation=permutation,
              whole_word_masking=whole_word_masking,
              favor_long_ngrams=favor_long_ngrams,
              extreme_masked_lm_prob=cfg.data.get(
                  "extreme_masked_lm_prob", 0.5
              ),
              extreme_max_ngram_size=cfg.data.get(
                  "extreme_max_ngram_size", 128
              ),
              extreme_mean_ngram_size=cfg.data.get(
                  "extreme_mean_ngram_size", 64
              ),
              extreme_min_ngram_size=cfg.data.get(
                  "extreme_min_ngram_size", 32
              ),
              prefix_lm_pivot_mean=cfg.data.get(
                  "prefix_lm_pivot_mean", 0.25
              ),
              respect_document_boundaries=respect_document_boundaries,
              documents=documents,
              **kwargs,
          )
      else:
          raise NotImplementedError(
              f"Dataset type {dataset_type} not fully implemented."
          )
      return dataset
  
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 10 for calling a global function with example usage: get_dataset(indexed_dataset, start_index, end_index, cfg, trainer, 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) and returns: dataset