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: Find the class folders in a dataset structured as follows::
  
      directory/
      ├── class_x
      │   ├── xxx.ext
      │   ├── xxy.ext
      │   └── ...
      │       └── xxz.ext
      └── class_y
          ├── 123.ext
          ├── nsdf3.ext
          └── ...
          └── asd932_.ext
  
  This method can be overridden to only consider
  a subset of classes, or to adapt to a different dataset directory structure.
  
  Args:
      directory(str): Root directory path, corresponding to ``self.root``
  
  Raises:
      FileNotFoundError: If ``dir`` has no class folders.
  
  Returns:
      (Tuple[List[str], Dict[str, int]]): List of all classes and dictionary mapping each class to an index.
docstr_tok: ["Find","the","class","folders","in","a","dataset","structured","as","follows",":",":","directory\/","\u251c\u2500\u2500","class_x","\u2502","\u251c\u2500\u2500","xxx.ext","\u2502","\u251c\u2500\u2500","xxy.ext","\u2502","\u2514\u2500\u2500","...","\u2502","\u2514\u2500\u2500","xxz.ext","\u2514\u2500\u2500","class_y","\u251c\u2500\u2500","123.ext","\u251c\u2500\u2500","nsdf3.ext","\u2514\u2500\u2500","...","\u2514\u2500\u2500","asd932_.ext","This","method","can","be","overridden","to","only","consider","a","subset","of","classes",",","or","to","adapt","to","a","different","dataset","directory","structure",".","Args",":","directory","(","str",")",":","Root","directory","path",",","corresponding","to","``","self.root","``","Raises",":","FileNotFoundError",":","If","``","dir","``","has","no","class","folders",".","Returns",":","(","Tuple","[","List","[","str","]",",","Dict","[","str",",","int","]","]",")",":","List","of","all","classes","and","dictionary","mapping","each","class","to","an","index","."]
code: def find_classes(
      self, directory: str
  ) -> Tuple[List[str], Dict[str, int]]:
      """Find the class folders in a dataset structured as follows::
  
          directory/
          ├── class_x
          │   ├── xxx.ext
          │   ├── xxy.ext
          │   └── ...
          │       └── xxz.ext
          └── class_y
              ├── 123.ext
              ├── nsdf3.ext
              └── ...
              └── asd932_.ext
  
      This method can be overridden to only consider
      a subset of classes, or to adapt to a different dataset directory structure.
  
      Args:
          directory(str): Root directory path, corresponding to ``self.root``
  
      Raises:
          FileNotFoundError: If ``dir`` has no class folders.
  
      Returns:
          (Tuple[List[str], Dict[str, int]]): List of all classes and dictionary mapping each class to an index.
      """
      return find_classes(directory)
  
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 3 for calling the DatasetFolder obj's underlying member method code with example usage: obj.find_classes(directory) and returns: find_classes