class_docstr: A generic data loader.
  
  This default directory structure can be customized by overriding the
  :meth:`find_classes` method.
  
  Args:
      root (string): Root directory path.
      loader (callable): A function to load a sample given its path.
      extensions (tuple[string]): A list of allowed extensions.
          both extensions and is_valid_file should not be passed.
      transform (callable, optional): A function/transform that takes in
          a sample and returns a transformed version.
          E.g, ``transforms.RandomCrop`` for images.
      target_transform (callable, optional): A function/transform that takes
          in the target and transforms it.
      is_valid_file (callable, optional): A function that takes path of a file
          and check if the file is a valid file (used to check of corrupt files)
          both extensions and is_valid_file should not be passed.
  
   Attributes:
      classes (list): List of the class names sorted alphabetically.
      class_to_idx (dict): Dict with items (class_name, class_index).
      samples (list): List of (sample path, class_index) tuples
      targets (list): The class_index value for each image in the dataset
docstr: Generates a list of samples of a form (path_to_sample, class).
  
  This can be overridden to e.g. read files from a compressed zip file instead of from the disk.
  
  Args:
      directory (str): root dataset directory, corresponding to ``self.root``.
      class_to_idx (Dict[str, int]): Dictionary mapping class name to class index.
      extensions (optional): A list of allowed extensions.
          Either extensions or is_valid_file should be passed. Defaults to None.
      is_valid_file (optional): A function that takes path of a file
          and checks if the file is a valid file
          (used to check of corrupt files) both extensions and
          is_valid_file should not be passed. Defaults to None.
  
  Raises:
      ValueError: In case ``class_to_idx`` is empty.
      ValueError: In case ``extensions`` and ``is_valid_file`` are None or both are not None.
      FileNotFoundError: In case no valid file was found for any class.
  
  Returns:
      List[Tuple[str, int]]: samples of a form (path_to_sample, class)
docstr_tok: ["Generates","a","list","of","samples","of","a","form","(","path_to_sample",",","class",")",".","This","can","be","overridden","to","e.g",".","read","files","from","a","compressed","zip","file","instead","of","from","the","disk",".","Args",":","directory","(","str",")",":","root","dataset","directory",",","corresponding","to","``","self.root","``",".","class_to_idx","(","Dict","[","str",",","int","]",")",":","Dictionary","mapping","class","name","to","class","index",".","extensions","(","optional",")",":","A","list","of","allowed","extensions",".","Either","extensions","or","is_valid_file","should","be","passed",".","Defaults","to","None",".","is_valid_file","(","optional",")",":","A","function","that","takes","path","of","a","file","and","checks","if","the","file","is","a","valid","file","(","used","to","check","of","corrupt","files",")","both","extensions","and","is_valid_file","should","not","be","passed",".","Defaults","to","None",".","Raises",":","ValueError",":","In","case","``","class_to_idx","``","is","empty",".","ValueError",":","In","case","``","extensions","``","and","``","is_valid_file","``","are","None","or","both","are","not","None",".","FileNotFoundError",":","In","case","no","valid","file","was","found","for","any","class",".","Returns",":","List","[","Tuple","[","str",",","int","]","]",":","samples","of","a","form","(","path_to_sample",",","class",")"]
code: def make_dataset(
      directory: str,
      class_to_idx: Dict[str, int],
      extensions: Optional[Tuple[str, ...]] = None,
      is_valid_file: Optional[Callable[[str], bool]] = None,
  ) -> List[Tuple[str, int]]:
      """Generates a list of samples of a form (path_to_sample, class).
  
      This can be overridden to e.g. read files from a compressed zip file instead of from the disk.
  
      Args:
          directory (str): root dataset directory, corresponding to ``self.root``.
          class_to_idx (Dict[str, int]): Dictionary mapping class name to class index.
          extensions (optional): A list of allowed extensions.
              Either extensions or is_valid_file should be passed. Defaults to None.
          is_valid_file (optional): A function that takes path of a file
              and checks if the file is a valid file
              (used to check of corrupt files) both extensions and
              is_valid_file should not be passed. Defaults to None.
  
      Raises:
          ValueError: In case ``class_to_idx`` is empty.
          ValueError: In case ``extensions`` and ``is_valid_file`` are None or both are not None.
          FileNotFoundError: In case no valid file was found for any class.
  
      Returns:
          List[Tuple[str, int]]: samples of a form (path_to_sample, class)
      """
      if class_to_idx is None:
          # prevent potential bug since make_dataset() would use the class_to_idx logic of the
          # find_classes() function, instead of using that of the find_classes() method, which
          # is potentially overridden and thus could have a different logic.
          raise ValueError("The class_to_idx parameter cannot be None.")
      return make_dataset(
          directory,
          class_to_idx,
          extensions=extensions,
          is_valid_file=is_valid_file,
      )
  
imports: import os
  import os.path
  from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Union
  from PIL import Image
  from .vision import VisionDataset
label_desc: Use image node_id 2 for calling the DatasetFolder obj's underlying member method code with example usage: obj.make_dataset(directory, class_to_idx, extensions, is_valid_file) and returns: make_dataset