class_docstr: Base Self Supervised Learning Dataset Class.
  
  The GenericSSLDataset class is defined to support reading data
  from multiple data sources. For example: data = [dataset1, dataset2]
  and the minibatches generated will have the corresponding data
  from each dataset.
  
  For this reason, we also support labels from multiple sources. For example
  targets = [dataset1 targets, dataset2 targets].
  
  In order to support multiple data sources, the dataset configuration
  always has list inputs.
      - DATA_SOURCES, LABEL_SOURCES, DATASET_NAMES, DATA_PATHS, LABEL_PATHS
  
  For several data sources, we also support specifying on what dataset the
  transforms should be applied. By default, apply the transforms
  on data from all datasets.
  
  Args:
      cfg (AttrDict): configuration defined by user
      split (str): the dataset split for which we are constructing the Dataset object
      dataset_source_map (Dict[str, Callable]): The dictionary that maps
                  what data sources are supported and what object to use to read
                  data from those sources. For example:
                  DATASET_SOURCE_MAP = {
                      "disk_filelist": DiskImageDataset,
                      "disk_folder": DiskImageDataset,
                      "synthetic": SyntheticImageDataset,
                  }
      data_sources_with_subset (Set[str]): the set of datasets for which the subset
                  operation is supported inside GenericSSLDataset
class_docstr_tok: ["Base","Self","Supervised","Learning","Dataset","Class",".","The","GenericSSLDataset","class","is","defined","to","support","reading","data","from","multiple","data","sources",".","For","example",":","data","=","[","dataset1",",","dataset2","]","and","the","minibatches","generated","will","have","the","corresponding","data","from","each","dataset",".","For","this","reason",",","we","also","support","labels","from","multiple","sources",".","For","example","targets","=","[","dataset1","targets",",","dataset2","targets","]",".","In","order","to","support","multiple","data","sources",",","the","dataset","configuration","always","has","list","inputs",".","-","DATA_SOURCES",",","LABEL_SOURCES",",","DATASET_NAMES",",","DATA_PATHS",",","LABEL_PATHS","For","several","data","sources",",","we","also","support","specifying","on","what","dataset","the","transforms","should","be","applied",".","By","default",",","apply","the","transforms","on","data","from","all","datasets",".","Args",":","cfg","(","AttrDict",")",":","configuration","defined","by","user","split","(","str",")",":","the","dataset","split","for","which","we","are","constructing","the","Dataset","object","dataset_source_map","(","Dict","[","str",",","Callable","]",")",":","The","dictionary","that","maps","what","data","sources","are","supported","and","what","object","to","use","to","read","data","from","those","sources",".","For","example",":","DATASET_SOURCE_MAP","=","{","``","disk_filelist","''",":","DiskImageDataset",",","``","disk_folder","''",":","DiskImageDataset",",","``","synthetic","''",":","SyntheticImageDataset",",","}","data_sources_with_subset","(","Set","[","str","]",")",":","the","set","of","datasets","for","which","the","subset","operation","is","supported","inside","GenericSSLDataset"]
docstr: Get the input sample for the minibatch for a specified data index.
  For each data object (if we are loading several datasets in a minibatch),
  we get the sample: consisting of {
      - image data,
      - label (if applicable) otherwise idx
      - data_valid: 0 or 1 indicating if the data is valid image
      - data_idx : index of the data in the dataset for book-keeping and debugging
  }
  
  Once the sample data is available, we apply the data transform on the sample.
  
  The final transformed sample is returned to be added into the minibatch.
docstr_tok: ["Get","the","input","sample","for","the","minibatch","for","a","specified","data","index",".","For","each","data","object","(","if","we","are","loading","several","datasets","in","a","minibatch",")",",","we","get","the","sample",":","consisting","of","{","-","image","data",",","-","label","(","if","applicable",")","otherwise","idx","-","data_valid",":","0","or","1","indicating","if","the","data","is","valid","image","-","data_idx",":","index","of","the","data","in","the","dataset","for","book-keeping","and","debugging","}","Once","the","sample","data","is","available",",","we","apply","the","data","transform","on","the","sample",".","The","final","transformed","sample","is","returned","to","be","added","into","the","minibatch","."]
code: def __getitem__(self, idx: int):
      """
      Get the input sample for the minibatch for a specified data index.
      For each data object (if we are loading several datasets in a minibatch),
      we get the sample: consisting of {
          - image data,
          - label (if applicable) otherwise idx
          - data_valid: 0 or 1 indicating if the data is valid image
          - data_idx : index of the data in the dataset for book-keeping and debugging
      }
  
      Once the sample data is available, we apply the data transform on the sample.
  
      The final transformed sample is returned to be added into the minibatch.
      """
      if not self.labels_init and len(self.label_sources) > 0:
          self.load_labels()
  
      subset_idx = idx
      if (
          self.data_limit >= 0
          and self._can_random_subset_data_sources()
      ):
          if not self._subset_initialized:
              self._init_image_and_label_subset()
          subset_idx = self.image_and_label_subset[idx]
  
      # TODO: this doesn't yet handle the case where the length of datasets
      # could be different.
      item = {"data": [], "data_valid": [], "data_idx": []}
      for data_source in self.data_objs:
          data, valid = data_source[subset_idx]
          item["data"].append(data)
          item["data_idx"].append(idx)
          item["data_valid"].append(1 if valid else -1)
  
      # There are three types of label_type (data labels): "standard",
      # "sample_index", and "zero". "standard" uses the labels associated
      # with a data set (e.g. directory names). "sample_index" assigns each
      # sample a label that corresponds to that sample's index in the
      # dataset (first sample will have label == 0, etc.), and is used for
      # SSL tasks in which the label is arbitrary. "zero" assigns
      # each sample the label == 0, which is necessary when using the
      # CutMixUp collator because of the label smoothing that is built in
      # to its functionality.
      if (len(self.label_objs) > 0) or self.label_type == "standard":
          item["label"] = []
          for label_source in self.label_objs:
              if isinstance(label_source, list):
                  lbl = [entry[subset_idx] for entry in label_source]
              else:
                  lbl = _convert_lbl_to_long(label_source[subset_idx])
              item["label"].append(lbl)
      elif self.label_type == "sample_index":
          item["label"] = []
          for _ in range(len(self.data_objs)):
              item["label"].append(idx)
      elif self.label_type == "zero":
          item["label"] = []
          for _ in range(len(self.data_objs)):
              item["label"].append(0)
      else:
          raise ValueError(f"Unknown label type: {self.label_type}")
  
      # apply the transforms on the image
      if self.transform:
          item = self.transform(item)
      return item
  
imports: import logging
  from typing import Any, Callable, Dict, Set
  import numpy
  from classy_vision.generic.distributed_util import get_world_size
  from iopath.common.file_io import g_pathmgr
  from vissl.config import AttrDict
  from vissl.data import dataset_catalog
  from vissl.data.data_helper import balanced_sub_sampling, unbalanced_sub_sampling
  from vissl.data.ssl_transforms import get_transform
  from vissl.data.vissl_dataset_base import VisslDatasetBase
  from vissl.utils.checkpoint import get_checkpoint_folder
  from vissl.utils.env import get_machine_local_and_dist_rank
  from vissl.utils.io import save_file
label_desc: Use image node_id 11 for calling the GenericSSLDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: item