code: def sample_image_folder(
      train_directory, target_size, color_mode="rgb", flat_dir=False
  ):
      # adjust train_directory
      classes = None
      if flat_dir and train_directory is not None:
          folder = train_directory
          if folder[-1] != os.sep:
              folder += os.sep
          parent = os.path.dirname(os.path.dirname(folder))
          folder_name = os.path.basename(os.path.dirname(folder))
          train_directory = parent
          classes = [folder_name]
  
      # sample images
      batch_size = 100
      img_gen = keras.preprocessing.image.ImageDataGenerator()
      batches = img_gen.flow_from_directory(
          directory=train_directory,
          classes=classes,
          target_size=target_size,
          batch_size=batch_size,
          color_mode=color_mode,
          shuffle=True,
      )
      the_shape = batches[0][0].shape
      sample_size = the_shape[0]
      if K.image_data_format() == "channels_first":
          num_channels = the_shape[1]
      else:
          num_channels = the_shape[-1]
      imgs, labels = next(batches)
      return imgs
  
imports: from ..None import utils
  from ..imports import *
  from .preprocessor import ImagePreprocessor
label_desc: Use image node_id 10 for calling a global function with example usage: sample_image_folder(train_directory, target_size, color_mode, flat_dir) and returns: imgs