docstr: Build a dictionary of datasets, keyed by split 'train', 'valid', 'test'.
  Download dataset and annotations automatically if not exist.
  
  Args:
      cfg (common.config.Config): _description_
  
  Returns:
      dict: Dictionary of torch.utils.data.Dataset objects by split.
docstr_tok: ["Build","a","dictionary","of","datasets",",","keyed","by","split","'train","'",",","'valid","'",",","'test","'",".","Download","dataset","and","annotations","automatically","if","not","exist",".","Args",":","cfg","(","common.config.Config",")",":","_description_","Returns",":","dict",":","Dictionary","of","torch.utils.data.Dataset","objects","by","split","."]
code: def build_datasets(self, cfg):
      """
      Build a dictionary of datasets, keyed by split 'train', 'valid', 'test'.
      Download dataset and annotations automatically if not exist.
  
      Args:
          cfg (common.config.Config): _description_
  
      Returns:
          dict: Dictionary of torch.utils.data.Dataset objects by split.
      """
  
      datasets = dict()
  
      datasets_config = cfg.datasets_cfg
  
      assert (
          len(datasets_config) > 0
      ), "At least one dataset has to be specified."
  
      for name in datasets_config:
          dataset_config = datasets_config[name]
          builder = registry.get_builder_class(name)(dataset_config)
          dataset = builder.build_datasets()
  
          datasets[name] = dataset
  
      return datasets
  
imports: import logging
  import os
  import torch
  import torch.distributed
  from lavis.common.dist_utils import get_rank, get_world_size, is_main_process, is_dist_avail_and_initialized
  from lavis.common.logger import MetricLogger, SmoothedValue
  from lavis.common.registry import registry
  from lavis.datasets.data_utils import prepare_sample
label_desc: Use image node_id 4 for calling the BaseTask obj's underlying member method code with example usage: obj.build_datasets(cfg) and returns: datasets