code: def test_generator_image_scan():
      num_of_sub_dirs = random.randint(1, 10)
      num_of_im_files = random.randint(1, 10)
  
      # Test with an absolute path
      output_directory = os.path.join(tempfile.mkdtemp(), "output_abs")
  
      # Make an empty temporary directory
      initial_temp_directory = tempfile.mkdtemp()
  
      sub_dirs = []
  
      # Make num_of_sub_dirs subdirectories of this initial directory
      for _ in range(num_of_sub_dirs):
          sub_dirs.append(tempfile.mkdtemp(dir=initial_temp_directory))
  
      tmp_files = []
      image_counter = 0
  
      # Just to mix things up, we can create different file types
      suffix_filetypes = [
          (".PNG", "PNG"),
          (".JPEG", "JPEG"),
          # ('.GIF', 'GIF'),
          (".JPG", "JPEG"),
          (".png", "PNG"),
          (".jpeg", "JPEG"),
          # ('.gif', 'GIF'),
          (".jpg", "JPEG"),
      ]
  
      # Make num_of_im_files images in each sub directory.
      for sub_dir in sub_dirs:
          for iterator in range(num_of_im_files):
              suffix_filetype = random.choice(suffix_filetypes)
              tmp_files.append(
                  tempfile.NamedTemporaryFile(
                      dir=os.path.abspath(sub_dir),
                      suffix=suffix_filetype[0],
                      delete=False,
                  )
              )
              im = Image.fromarray(
                  np.uint8(np.random.rand(80, 80, 3) * 255)
              )
              im.save(tmp_files[image_counter].name, suffix_filetype[1])
              image_counter += 1
  
      p = Augmentor.Pipeline(
          initial_temp_directory, output_directory=output_directory
      )
  
      batch_size = random.randint(1, 1000)
  
      g = p.keras_generator(batch_size=batch_size)
  
      X, y = next(g)
  
      # The number of classes must equal the number of sub directories
      assert np.shape(y)[0] == batch_size
      assert np.shape(y)[1] == num_of_sub_dirs
      assert len(y) == batch_size
  
      # Call the generator again: this time the output directory will contain the
      # the created output_directory directory.
      g_2 = p.keras_generator(batch_size=batch_size)
      X_2, y_2 = next(g_2)
  
      assert np.shape(y_2)[0] == batch_size
      assert np.shape(y_2)[1] == num_of_sub_dirs
      assert len(y_2) == batch_size
  
      # Clean up
      for tmp_file in tmp_files:
          tmp_file.close()
  
      for sub_dir in sub_dirs:
          shutil.rmtree(sub_dir)
  
      shutil.rmtree(
          os.path.join(initial_temp_directory, output_directory)
      )
      shutil.rmtree(initial_temp_directory)
  
file_path: Augmentor/tests/test_generators.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from builtins import *
  import os
  import sys
  import Augmentor
  import tempfile
  import io
  import shutil
  import glob
  import random
  import numpy
  from PIL import Image
  from Augmentor import ImageUtilities
label_desc: Use image node_id 5 for calling a global function with example usage: test_generator_image_scan() without return types