code: def images_from_folder(
      datadir,
      target_size=(224, 224),
      classes=None,
      color_mode="rgb",
      train_test_names=["train", "test"],
      data_aug=None,
      verbose=1,
  ):
      """
      ```
      Returns image generator (Iterator instance).
      Assumes output will be 2D one-hot-encoded labels for categorization.
      Note: This function preprocesses the input in preparation
            for a ResNet50 model.
  
      Args:
      datadir (string): path to training (or validation/test) dataset
          Assumes folder follows this structure:
          ├── datadir
          │   ├── train
          │   │   ├── class0       # folder containing documents of class 0
          │   │   ├── class1       # folder containing documents of class 1
          │   │   ├── class2       # folder containing documents of class 2
          │   │   └── classN       # folder containing documents of class N
          │   └── test
          │       ├── class0       # folder containing documents of class 0
          │       ├── class1       # folder containing documents of class 1
          │       ├── class2       # folder containing documents of class 2
          │       └── classN       # folder containing documents of class N
  
      target_size (tuple):  image dimensions
      classes (list):  optional list of class subdirectories (e.g., ['cats','dogs'])
      color_mode (string):  color mode
      train_test_names(list): names for train and test subfolders
      data_aug(ImageDataGenerator):  a keras.preprocessing.image.ImageDataGenerator
                                    for data augmentation
      verbose (bool):               verbosity
  
      Returns:
      batches: a tuple of two Iterators - one for train and one for test
      ```
      """
  
      # train/test names
      train_str = train_test_names[0]
      test_str = train_test_names[1]
      train_dir = os.path.join(datadir, train_str)
      test_dir = os.path.join(datadir, test_str)
  
      # color mode warning
      if PIL_INSTALLED:
          inferred_color_mode = detect_color_mode(train_dir)
          if inferred_color_mode is not None and (
              inferred_color_mode != color_mode
          ):
              U.vprint(
                  "color_mode detected (%s) different than color_mode selected (%s)"
                  % (inferred_color_mode, color_mode),
                  verbose=verbose,
              )
  
      # get train and test data generators
      (train_datagen, test_datagen) = process_datagen(
          data_aug,
          train_directory=train_dir,
          target_size=target_size,
          color_mode=color_mode,
      )
      batches_tr = train_datagen.flow_from_directory(
          train_dir,
          target_size=target_size,
          classes=classes,
          class_mode="categorical",
          shuffle=True,
          interpolation="bicubic",
          color_mode=color_mode,
      )
  
      batches_te = test_datagen.flow_from_directory(
          test_dir,
          target_size=target_size,
          classes=classes,
          class_mode="categorical",
          shuffle=False,
          interpolation="bicubic",
          color_mode=color_mode,
      )
  
      # setup preprocessor
      class_tup = sorted(
          batches_tr.class_indices.items(), key=operator.itemgetter(1)
      )
      preproc = ImagePreprocessor(
          test_datagen,
          [x[0] for x in class_tup],
          target_size=target_size,
          color_mode=color_mode,
      )
      return (batches_tr, batches_te, preproc)
  
imports: from ..None import utils
  from ..imports import *
  from .preprocessor import ImagePreprocessor
label_desc: Use image node_id 13 for calling a global function with example usage: images_from_folder(datadir, target_size, classes, color_mode, train_test_names, data_aug, verbose) and returns: batches_tr,  batches_te,  preproc