class_docstr: A generic data loader where the samples are arranged in this way: ::
  
      root/class_x/xxx.ext
      root/class_x/xxy.ext
      root/class_x/xxz.ext
  
      root/class_y/123.ext
      root/class_y/nsdf3.ext
      root/class_y/asd932_.ext
  
  Args:
      root (string): Root directory path.
      loader (callable): A function to load a sample given its path.
      extensions (list[string]): A list of allowed extensions.
      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.
  
   Attributes:
      classes (list): List of the class names.
      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
class_docstr_tok: ["A","generic","data","loader","where","the","samples","are","arranged","in","this","way",":",":",":","root\/class_x\/xxx.ext","root\/class_x\/xxy.ext","root\/class_x\/xxz.ext","root\/class_y\/123.ext","root\/class_y\/nsdf3.ext","root\/class_y\/asd932_.ext","Args",":","root","(","string",")",":","Root","directory","path",".","loader","(","callable",")",":","A","function","to","load","a","sample","given","its","path",".","extensions","(","list","[","string","]",")",":","A","list","of","allowed","extensions",".","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",".","Attributes",":","classes","(","list",")",":","List","of","the","class","names",".","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: Finds the class folders in a dataset.
  
  Args:
      dir (string): Root directory path.
  
  Returns:
      tuple: (classes, class_to_idx) where classes are relative to (dir), and class_to_idx is a dictionary.
  
  Ensures:
      No class is a subdirectory of another.
docstr_tok: ["Finds","the","class","folders","in","a","dataset",".","Args",":","dir","(","string",")",":","Root","directory","path",".","Returns",":","tuple",":","(","classes",",","class_to_idx",")","where","classes","are","relative","to","(","dir",")",",","and","class_to_idx","is","a","dictionary",".","Ensures",":","No","class","is","a","subdirectory","of","another","."]
code: def _find_classes(self, dir):
      """
      Finds the class folders in a dataset.
  
      Args:
          dir (string): Root directory path.
  
      Returns:
          tuple: (classes, class_to_idx) where classes are relative to (dir), and class_to_idx is a dictionary.
  
      Ensures:
          No class is a subdirectory of another.
      """
      if sys.version_info >= (3, 5):
          # Faster and available in Python 3.5 and above
          classes = [d.name for d in os.scandir(dir) if d.is_dir()]
      else:
          classes = [
              d
              for d in os.listdir(dir)
              if os.path.isdir(os.path.join(dir, d))
          ]
      classes.sort()
      class_to_idx = {classes[i]: i for i in range(len(classes))}
      return classes, class_to_idx
  
imports: import torch.utils.data
  from torch.utils.data import Dataset
  from torchvision import transforms
  from PIL import Image
  import os
  import os.path
  import sys
label_desc: Use image node_id 2 for calling the DatasetFolder obj's underlying member method code with example usage: obj._find_classes(dir) and returns: classes,  class_to_idx