code: def build_train_valid_test_data_loaders(
      build_train_valid_test_datasets_provider,
  ):
      """Build pretraining data loaders."""
  
      args = get_args()
  
      (train_dataloader, valid_dataloader, test_dataloader) = (
          None,
          None,
          None,
      )
  
      print_rank_0(
          "> building train, validation, and test datasets ..."
      )
  
      # Backward compatibility, assume fixed batch size.
      if args.iteration > 0 and args.consumed_train_samples == 0:
          assert (
              args.train_samples is None
          ), "only backward compatiblity support for iteration-based training"
          args.consumed_train_samples = (
              args.iteration * args.global_batch_size
          )
      if args.iteration > 0 and args.consumed_valid_samples == 0:
          if args.train_samples is None:
              args.consumed_valid_samples = (
                  (args.iteration // args.eval_interval)
                  * args.eval_iters
                  * args.global_batch_size
              )
  
      # Rely on distributed-aware core datasets, temporary
      is_distributed = getattr(
          build_train_valid_test_datasets_provider,
          "is_distributed",
          False,
      )
  
      # Construct the data pipeline
      if is_distributed or mpu.get_tensor_model_parallel_rank() == 0:
          # Build datasets.
          train_ds, valid_ds, test_ds = build_train_valid_test_datasets(
              build_train_valid_test_datasets_provider
          )
          # Build dataloders.
          train_dataloader = build_pretraining_data_loader(
              train_ds, args.consumed_train_samples
          )
          if args.skip_train:
              valid_dataloader = build_pretraining_data_loader(
                  valid_ds, 0
              )
          else:
              valid_dataloader = build_pretraining_data_loader(
                  valid_ds, args.consumed_valid_samples
              )
          test_dataloader = build_pretraining_data_loader(test_ds, 0)
  
          # Flags to know if we need to do training/validation/testing.
          do_train = (
              train_dataloader is not None and args.train_iters > 0
          )
          do_valid = (
              valid_dataloader is not None and args.eval_iters > 0
          )
          do_test = test_dataloader is not None and args.eval_iters > 0
          flags = torch.tensor(
              [int(do_train), int(do_valid), int(do_test)],
              dtype=torch.long,
              device="cuda",
          )
      else:
          flags = torch.tensor(
              [0, 0, 0], dtype=torch.long, device="cuda"
          )
  
      torch.distributed.broadcast(flags, 0)
  
      args.do_train = (
          getattr(args, "do_train", False) or flags[0].item()
      )
      args.do_valid = (
          getattr(args, "do_valid", False) or flags[1].item()
      )
      args.do_test = getattr(args, "do_test", False) or flags[2].item()
  
      return train_dataloader, valid_dataloader, test_dataloader
  
imports: import gc
  from datetime import datetime
  import math
  import logging
  import sys
  from .log_handler import CustomHandler
  from .theoretical_memory_usage import report_theoretical_memory
  import time
  import torch
  from megatron import get_args
  from megatron import get_signal_handler
  from megatron import get_timers
  from megatron import get_tensorboard_writer
  from megatron import get_wandb_writer
  from megatron import get_current_global_batch_size
  from megatron import get_num_microbatches
  from megatron import is_last_rank
  from megatron import update_num_microbatches
  from megatron.core import mpu, tensor_parallel
  from megatron.core.utils import get_model_config
  from megatron import print_rank_0
  from megatron import print_rank_last
  from megatron.checkpointing import load_checkpoint
  from megatron.checkpointing import save_checkpoint
  from megatron.model import Float16Module
  from megatron.model import GPTModel
  from megatron.core.distributed import DistributedDataParallel
  from megatron.core.distributed import finalize_model_grads
  from megatron.core.enums import ModelType
  from megatron.optimizer import get_megatron_optimizer
  from megatron.initialize import initialize_megatron
  from megatron.initialize import write_args_to_tensorboard
  from megatron.initialize import set_jit_fusion_options
  from megatron.optimizer_param_scheduler import OptimizerParamScheduler
  from megatron.utils import check_adlr_autoresume_termination
  from megatron.utils import unwrap_model
  from megatron.data.data_samplers import build_pretraining_data_loader
  from megatron.utils import calc_params_l2_norm
  from megatron.core.pipeline_parallel import get_forward_backward_func
  from megatron.utils import report_memory
  from megatron.model.vision.knn_monitor import compute_feature_bank
label_desc: Use image node_id 16 for calling a global function with example usage: build_train_valid_test_data_loaders(build_train_valid_test_datasets_provider) and returns: train_dataloader,  valid_dataloader,  test_dataloader