class_docstr: `CIFAR10 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ Dataset.
  
  Args:
      root (string): Root directory of dataset where directory
          ``cifar-10-batches-py`` exists or will be saved to if download is set to True.
      train (bool, optional): If True, creates dataset from training set, otherwise
          creates from test set.
      transform (callable, optional): A function/transform that takes in a PIL image
          and returns a transformed version. E.g, ``transforms.RandomCrop``
      target_transform (callable, optional): A function/transform that takes in the
          target and transforms it.
      download (bool, optional): If true, downloads the dataset from the internet and
          puts it in root directory. If dataset is already downloaded, it is not
          downloaded again.
class_docstr_tok: ["`","CIFAR10","<","https",":","\/\/www.cs.toronto.edu\/~kriz\/cifar.html",">","`","_","Dataset",".","Args",":","root","(","string",")",":","Root","directory","of","dataset","where","directory","``","cifar-10-batches-py","``","exists","or","will","be","saved","to","if","download","is","set","to","True",".","train","(","bool",",","optional",")",":","If","True",",","creates","dataset","from","training","set",",","otherwise","creates","from","test","set",".","transform","(","callable",",","optional",")",":","A","function\/transform","that","takes","in","a","PIL","image","and","returns","a","transformed","version",".","E.g",",","``","transforms.RandomCrop","``","target_transform","(","callable",",","optional",")",":","A","function\/transform","that","takes","in","the","target","and","transforms","it",".","download","(","bool",",","optional",")",":","If","true",",","downloads","the","dataset","from","the","internet","and","puts","it","in","root","directory",".","If","dataset","is","already","downloaded",",","it","is","not","downloaded","again","."]
code: def __init__(
      self,
      root: str,
      train: bool = True,
      transform: Optional[Callable] = None,
      target_transform: Optional[Callable] = None,
      download: bool = False,
  ) -> None:
      super().__init__(
          root, transform=transform, target_transform=target_transform
      )
  
      self.train = train  # training set or test set
  
      if download:
          self.download()
  
      if not self._check_integrity():
          raise RuntimeError(
              "Dataset not found or corrupted. You can use download=True to download it"
          )
  
      if self.train:
          downloaded_list = self.train_list
      else:
          downloaded_list = self.test_list
  
      self.data: Any = []
      self.targets = []
  
      # now load the picked numpy arrays
      for file_name, checksum in downloaded_list:
          file_path = os.path.join(
              self.root, self.base_folder, file_name
          )
          with open(file_path, "rb") as f:
              entry = pickle.load(f, encoding="latin1")
              self.data.append(entry["data"])
              if "labels" in entry:
                  self.targets.extend(entry["labels"])
              else:
                  self.targets.extend(entry["fine_labels"])
  
      self.data = np.vstack(self.data).reshape(-1, 3, 32, 32)
      self.data = self.data.transpose((0, 2, 3, 1))  # convert to HWC
  
      self._load_meta()
  
file_path: vision/torchvision/datasets/cifar.py
imports: import os.path
  import pickle
  from typing import Any, Callable, Optional, Tuple
  import numpy
  from PIL import Image
  from .utils import check_integrity, download_and_extract_archive
  from .vision import VisionDataset
label_desc: Use image node_id 1 to create a new CIFAR10 object from inherited base classes: VisionDataset with example: obj = CIFAR10(root, train, transform, target_transform, download)