class_docstr: `SBU Captioned Photo <http://www.cs.virginia.edu/~vicente/sbucaptions/>`_ Dataset.
  
  Args:
      root (string): Root directory of dataset where tarball
          ``SBUCaptionedPhotoDataset.tar.gz`` exists.
      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 = True,
  ) -> None:
      super().__init__(
          root, transform=transform, target_transform=target_transform
      )
  
      if download:
          self.download()
  
      if not self._check_integrity():
          raise RuntimeError(
              "Dataset not found or corrupted. You can use download=True to download it"
          )
  
      # Read the caption for each photo
      self.photos = []
      self.captions = []
  
      file1 = os.path.join(
          self.root, "dataset", "SBU_captioned_photo_dataset_urls.txt"
      )
      file2 = os.path.join(
          self.root,
          "dataset",
          "SBU_captioned_photo_dataset_captions.txt",
      )
  
      for line1, line2 in zip(open(file1), open(file2)):
          url = line1.rstrip()
          photo = os.path.basename(url)
          filename = os.path.join(self.root, "dataset", photo)
          if os.path.exists(filename):
              caption = line2.rstrip()
              self.photos.append(photo)
              self.captions.append(caption)
  
file_path: vision/torchvision/datasets/sbu.py
imports: import os
  from typing import Any, Callable, Optional, Tuple
  from PIL import Image
  from .utils import check_integrity, download_and_extract_archive, download_url
  from .vision import VisionDataset
label_desc: Use image node_id 1 to create a new SBU object from inherited base classes: VisionDataset with example: obj = SBU(root, transform, target_transform, download)