code: def images_from_fname(
      train_folder,
      pattern=r"([^/]+)_\d+.jpg$",
      val_folder=None,
      is_regression=False,
      target_size=(224, 224),
      color_mode="rgb",
      data_aug=None,
      val_pct=0.1,
      random_state=None,
      verbose=1,
  ):
      """
      ```
      Returns image generator (Iterator instance).
  
      Args:
      train_folder (str): directory containing images
      pat (str):  regular expression to extract class from file name of each image
                  Example: r'([^/]+)_\d+.jpg$' to match 'english_setter' in 'english_setter_140.jpg'
                  By default, it will extract classes from file names of the form:
                     <class_name>_<numbers>.jpg
      val_folder (str): directory containing validation images. default:None
      is_regression(bool): If True, task is treated as regression.
                           Used when there is single column of numeric values and
                           numeric values should be treated as numeric targets as opposed to class labels
      target_size (tuple):  image dimensions
      color_mode (string):  color mode
      data_aug(ImageDataGenerator):  a keras.preprocessing.image.ImageDataGenerator
                                    for data augmentation
      val_pct(float):  proportion of training data to be used for validation
                       only used if val_folder is None
      random_state(int): random seed for train/test split
      verbose(bool):   verbosity
  
      Returns:
      batches: a tuple of two Iterators - one for train and one for test
      ```
      """
  
      image_column = "image_name"
      label_column = "label"
      train_df = _img_fnames_to_df(
          train_folder,
          pattern,
          image_column=image_column,
          label_column=label_column,
          verbose=verbose,
      )
      val_df = None
      if val_folder is not None:
          val_df = _img_fnames_to_df(
              val_folder,
              pattern,
              image_column=image_column,
              label_column=label_column,
              verbose=verbose,
          )
      return images_from_df(
          train_df,
          image_column,
          label_columns=label_column,
          directory=train_folder,
          val_directory=val_folder,
          val_df=val_df,
          is_regression=is_regression,
          target_size=target_size,
          color_mode=color_mode,
          data_aug=data_aug,
          val_pct=val_pct,
          random_state=random_state,
      )
  
imports: from ..None import utils
  from ..imports import *
  from .preprocessor import ImagePreprocessor
label_desc: Use image node_id 16 for calling a global function with example usage: images_from_fname(train_folder, pattern, val_folder, is_regression, target_size, color_mode, data_aug, val_pct, random_state, verbose) and returns: images_from_df