code: def build_pretraining_data_loader(dataset, consumed_samples):
      """Buld dataloader given an input dataset."""
  
      if dataset is None:
          return None
      args = get_args()
  
      # Megatron sampler
      if args.dataloader_type == "single":
          batch_sampler = MegatronPretrainingSampler(
              total_samples=len(dataset),
              consumed_samples=consumed_samples,
              micro_batch_size=args.micro_batch_size,
              data_parallel_rank=mpu.get_data_parallel_rank(),
              data_parallel_size=mpu.get_data_parallel_world_size(),
          )
      elif args.dataloader_type == "cyclic":
          batch_sampler = MegatronPretrainingRandomSampler(
              dataset,
              total_samples=len(dataset),
              consumed_samples=consumed_samples,
              micro_batch_size=args.micro_batch_size,
              data_parallel_rank=mpu.get_data_parallel_rank(),
              data_parallel_size=mpu.get_data_parallel_world_size(),
              data_sharding=args.data_sharding,
          )
      else:
          raise Exception(
              "{} dataloader type is not supported.".format(
                  args.dataloader_type
              )
          )
  
      # Torch dataloader.
      return torch.utils.data.DataLoader(
          dataset,
          batch_sampler=batch_sampler,
          num_workers=args.num_workers,
          pin_memory=True,
          persistent_workers=True if args.num_workers > 0 else False,
      )
  
imports: import random
  import torch
  import numpy
  from torch.utils.data import Dataset
  from megatron import get_args
  from megatron.core import mpu
label_desc: Use image node_id 1 for calling a global function with example usage: build_pretraining_data_loader(dataset, consumed_samples) and returns: torch, None