class_docstr: `SVHN <http://ufldl.stanford.edu/housenumbers/>`_ Dataset.
  Note: The SVHN dataset assigns the label `10` to the digit `0`. However, in this Dataset,
  we assign the label `0` to the digit `0` to be compatible with PyTorch loss functions which
  expect the class labels to be in the range `[0, C-1]`
  
  .. warning::
  
      This class needs `scipy <https://docs.scipy.org/doc/>`_ to load data from `.mat` format.
  
  Args:
      root (string): Root directory of the dataset where the data is stored.
      split (string): One of {'train', 'test', 'extra'}.
          Accordingly dataset is selected. 'extra' is Extra training 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,
      split: str = "train",
      transform: Optional[Callable] = None,
      target_transform: Optional[Callable] = None,
      download: bool = False,
  ) -> None:
      super().__init__(
          root, transform=transform, target_transform=target_transform
      )
      self.split = verify_str_arg(
          split, "split", tuple(self.split_list.keys())
      )
      self.url = self.split_list[split][0]
      self.filename = self.split_list[split][1]
      self.file_md5 = self.split_list[split][2]
  
      if download:
          self.download()
  
      if not self._check_integrity():
          raise RuntimeError(
              "Dataset not found or corrupted. You can use download=True to download it"
          )
  
      # import here rather than at top of file because this is
      # an optional dependency for torchvision
      import scipy.io as sio
  
      # reading(loading) mat file as array
      loaded_mat = sio.loadmat(os.path.join(self.root, self.filename))
  
      self.data = loaded_mat["X"]
      # loading from the .mat file gives an np.ndarray of type np.uint8
      # converting to np.int64, so that we have a LongTensor after
      # the conversion from the numpy array
      # the squeeze is needed to obtain a 1D tensor
      self.labels = loaded_mat["y"].astype(np.int64).squeeze()
  
      # the svhn dataset assigns the class label "10" to the digit 0
      # this makes it inconsistent with several loss functions
      # which expect the class labels to be in the range [0, C-1]
      np.place(self.labels, self.labels == 10, 0)
      self.data = np.transpose(self.data, (3, 2, 0, 1))
  
file_path: vision/torchvision/datasets/svhn.py
imports: import os.path
  from typing import Any, Callable, Optional, Tuple
  import numpy
  from PIL import Image
  from .utils import check_integrity, download_url, verify_str_arg
  from .vision import VisionDataset
label_desc: Use image node_id 1 to create a new SVHN object from inherited base classes: VisionDataset with example: obj = SVHN(root, split, transform, target_transform, download)