class_docstr: Base Class For making datasets which are compatible with torchvision.
  It is necessary to override the ``__getitem__`` and ``__len__`` method.
  
  Args:
      root (string, optional): Root directory of dataset. Only used for `__repr__`.
      transforms (callable, optional): A function/transforms that takes in
          an image and a label and returns the transformed versions of both.
      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.
  
  .. note::
  
      :attr:`transforms` and the combination of :attr:`transform` and :attr:`target_transform` are mutually exclusive.
class_docstr_tok: ["Base","Class","For","making","datasets","which","are","compatible","with","torchvision",".","It","is","necessary","to","override","the","``","__getitem__","``","and","``","__len__","``","method",".","Args",":","root","(","string",",","optional",")",":","Root","directory","of","dataset",".","Only","used","for","`","__repr__","`",".","transforms","(","callable",",","optional",")",":","A","function\/transforms","that","takes","in","an","image","and","a","label","and","returns","the","transformed","versions","of","both",".","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",".","..","note",":",":",":","attr",":","`","transforms","`","and","the","combination","of",":","attr",":","`","transform","`","and",":","attr",":","`","target_transform","`","are","mutually","exclusive","."]
code: def __init__(
      self,
      root: str = None,  # type: ignore[assignment]
      transforms: Optional[Callable] = None,
      transform: Optional[Callable] = None,
      target_transform: Optional[Callable] = None,
  ) -> None:
      _log_api_usage_once(self)
      if isinstance(root, str):
          root = os.path.expanduser(root)
      self.root = root
  
      has_transforms = transforms is not None
      has_separate_transform = (
          transform is not None or target_transform is not None
      )
      if has_transforms and has_separate_transform:
          raise ValueError(
              "Only transforms or transform/target_transform can be passed as argument"
          )
  
      # for backwards-compatibility
      self.transform = transform
      self.target_transform = target_transform
  
      if has_separate_transform:
          transforms = StandardTransform(transform, target_transform)
      self.transforms = transforms
  
file_path: vision/torchvision/datasets/vision.py
imports: import os
  from typing import Any, Callable, List, Optional, Tuple
  import torch.utils.data
  from ..utils import _log_api_usage_once
label_desc: Use image node_id 1 to create a new VisionDataset object from inherited base classes: data with example: obj = VisionDataset(root, transforms, transform, target_transform)