class_docstr: `Caltech 256 <https://data.caltech.edu/records/20087>`_ Dataset.
  
  Args:
      root (string): Root directory of dataset where directory
          ``caltech256`` exists or will be saved to if download is set to True.
      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: ["`","Caltech","256","<","https",":","\/\/data.caltech.edu\/records\/20087",">","`","_","Dataset",".","Args",":","root","(","string",")",":","Root","directory","of","dataset","where","directory","``","caltech256","``","exists","or","will","be","saved","to","if","download","is","set","to","True",".","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,
      transform: Optional[Callable] = None,
      target_transform: Optional[Callable] = None,
      download: bool = False,
  ) -> None:
      super().__init__(
          os.path.join(root, "caltech256"),
          transform=transform,
          target_transform=target_transform,
      )
      os.makedirs(self.root, exist_ok=True)
  
      if download:
          self.download()
  
      if not self._check_integrity():
          raise RuntimeError(
              "Dataset not found or corrupted. You can use download=True to download it"
          )
  
      self.categories = sorted(
          os.listdir(os.path.join(self.root, "256_ObjectCategories"))
      )
      self.index: List[int] = []
      self.y = []
      for i, c in enumerate(self.categories):
          n = len(
              [
                  item
                  for item in os.listdir(
                      os.path.join(self.root, "256_ObjectCategories", c)
                  )
                  if item.endswith(".jpg")
              ]
          )
          self.index.extend(range(1, n + 1))
          self.y.extend(n * [i])
  
imports: import os
  import os.path
  from typing import Any, Callable, List, Optional, Tuple, Union
  from PIL import Image
  from .utils import download_and_extract_archive, verify_str_arg
  from .vision import VisionDataset
label_desc: Use image node_id 1 to create a new Caltech256 object from inherited base classes: VisionDataset with example: obj = Caltech256(root, transform, target_transform, download)