code: def find_images_and_targets(
      folder,
      types=IMG_EXTENSIONS,
      class_to_idx=None,
      leaf_name_only=True,
      sort=True,
  ):
      if class_to_idx is None:
          class_to_idx = dict()
          build_class_idx = True
      else:
          build_class_idx = False
      labels = []
      filenames = []
      for root, subdirs, files in os.walk(folder, topdown=False):
          rel_path = (
              os.path.relpath(root, folder) if (root != folder) else ""
          )
          label = (
              os.path.basename(rel_path)
              if leaf_name_only
              else rel_path.replace(os.path.sep, "_")
          )
          if build_class_idx and not subdirs:
              class_to_idx[label] = None
          for f in files:
              base, ext = os.path.splitext(f)
              if ext.lower() in types:
                  filenames.append(os.path.join(root, f))
                  labels.append(label)
      if build_class_idx:
          classes = sorted(class_to_idx.keys(), key=natural_key)
          for idx, c in enumerate(classes):
              class_to_idx[c] = idx
      images_and_targets = zip(
          filenames, [class_to_idx[l] for l in labels]
      )
      if sort:
          images_and_targets = sorted(
              images_and_targets, key=lambda k: natural_key(k[0])
          )
      if build_class_idx:
          return images_and_targets, classes, class_to_idx
      else:
          return images_and_targets
  
file_path: gen-efficientnet-pytorch/data/dataset.py
imports: import torch.utils.data
  import os
  import re
  import torch
  from PIL import Image
label_desc: Use image node_id 2 for calling a global function with example usage: find_images_and_targets(folder, types, class_to_idx, leaf_name_only, sort) and returns: images_and_targets,  classes,  class_to_idx, images_and_targets