code: def data_loaders_from_params(
      params: Params,
      train: bool = True,
      validation: bool = True,
      test: bool = True,
      serialization_dir: Optional[Union[str, PathLike]] = None,
  ) -> Dict[str, DataLoader]:
      """
      Instantiate data loaders specified by the config.
      """
      data_loaders: Dict[str, DataLoader] = {}
  
      train = train and ("train_data_path" in params)
      validation = validation and ("validation_data_path" in params)
      test = test and ("test_data_path" in params)
      if not any((train, validation, test)):
          # Return early so don't unnecessarily initialize the train data reader.
          return data_loaders
  
      dataset_reader_params = params.pop("dataset_reader")
      dataset_reader = DatasetReader.from_params(
          dataset_reader_params, serialization_dir=serialization_dir
      )
      data_loader_params = params.pop("data_loader")
  
      if train:
          train_data_path = params.pop("train_data_path")
          logger.info("Reading training data from %s", train_data_path)
          data_loaders["train"] = DataLoader.from_params(
              data_loader_params.duplicate(),
              reader=dataset_reader,
              data_path=train_data_path,
          )
  
      if not validation and not test:
          # Return early so we don't unnecessarily initialize the validation/test data
          # reader.
          return data_loaders
  
      validation_and_test_dataset_reader: DatasetReader = dataset_reader
      validation_dataset_reader_params = params.pop(
          "validation_dataset_reader", None
      )
      if validation_dataset_reader_params is not None:
          logger.info(
              "Using a separate dataset reader to load validation and test data."
          )
          validation_and_test_dataset_reader = (
              DatasetReader.from_params(
                  validation_dataset_reader_params,
                  serialization_dir=serialization_dir,
              )
          )
  
      validation_data_loader_params = params.pop(
          "validation_data_loader", data_loader_params
      )
  
      if validation:
          validation_data_path = params.pop("validation_data_path")
          logger.info(
              "Reading validation data from %s", validation_data_path
          )
          data_loaders["validation"] = DataLoader.from_params(
              validation_data_loader_params.duplicate(),
              reader=validation_and_test_dataset_reader,
              data_path=validation_data_path,
          )
  
      if test:
          test_data_path = params.pop("test_data_path")
          logger.info("Reading test data from %s", test_data_path)
          data_loaders["test"] = DataLoader.from_params(
              validation_data_loader_params,
              reader=validation_and_test_dataset_reader,
              data_path=test_data_path,
          )
  
      return data_loaders
  
imports: import datetime
  import logging
  import os
  import shutil
  import json
  from os import PathLike
  from typing import Any, Dict, Iterable, Optional, Union, Tuple, Set, List
  from collections import Counter
  import torch
  from torch.nn.utils import clip_grad_norm_
  from allennlp.common.checks import check_for_gpu, ConfigurationError
  from allennlp.common.params import Params
  from allennlp.common.tqdm import Tqdm
  from allennlp.common.util import dump_metrics, sanitize, int_to_device
  from allennlp.data import Instance, Vocabulary, Batch, DataLoader
  from allennlp.data.dataset_readers import DatasetReader
  from allennlp.models.archival import CONFIG_NAME
  from allennlp.models.model import Model
  from allennlp.nn import util
label_desc: Use image node_id 5 for calling a global function with example usage: data_loaders_from_params(params, train, validation, test, serialization_dir) and returns: data_loaders, data_loaders, data_loaders