code: def build_dataset(dataset_list, transforms, dataset_catalog, is_train=True):
      
      if not isinstance(dataset_list, (list, tuple)):
          raise RuntimeError(
              "dataset_list should be a list of strings, got {}".format(dataset_list)
          )
      datasets = []
      total_datasets_size = 0
      for dataset_name in dataset_list:
          data = dataset_catalog.get(dataset_name)
          factory = getattr(D, data["factory"])
          args = data["args"]
          # for COCODataset, we want to remove images without annotations
          # during training
          if data["factory"] == "COCODataset":
              args["remove_images_without_annotations"] = is_train
          if data["factory"] == "PascalVOCDataset":
              args["use_difficult"] = not is_train
          args["transforms"] = transforms
          # make dataset from factory
          dataset = factory(**args)
          total_datasets_size += len(dataset)
          datasets.append(dataset)
  
      # for testing, return a list of datasets
      if not is_train:
          return datasets, total_datasets_size
  
      # for training, concatenate all datasets into a single one
      dataset = datasets[0]
      if len(datasets) > 1:
          dataset = D.ConcatDataset(datasets)
  
      return [dataset], total_datasets_size
docs: Arguments:
          dataset_list (list[str]): Contains the names of the datasets, i.e.,
              coco_2014_trian, coco_2014_val, etc
          transforms (callable): transforms to apply to each (image, target) sample
          dataset_catalog (DatasetCatalog): contains the information on how to
              construct a dataset.
          is_train (bool): whether to setup the dataset for training or testing