code: def test_class_image_scan():
      # Some constants
      num_of_sub_dirs = random.randint(1, 10)
      num_of_im_files = random.randint(1, 10)
  
      output_directory = "some_folder"
  
      # 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
  
      # Make a folder within the root directory with the same name as the output directory,
      # it should be ignored and all the tests should still run fine
      os.mkdir(os.path.join(initial_temp_directory, output_directory))
  
      def run():
          p = Augmentor.Pipeline(
              initial_temp_directory, output_directory=output_directory
          )
  
          assert len(p.augmentor_images) == (
              num_of_sub_dirs * num_of_im_files
          )
          assert len(p.class_labels) == num_of_sub_dirs
  
          class_label_strings = [x[0] for x in p.class_labels]
          for sub_dir in sub_dirs:
              assert os.path.basename(sub_dir) in class_label_strings
  
          unique_class_labels = [
              x.class_label for x in p.augmentor_images
          ]
          unique_class_labels = set(unique_class_labels)
          unique_class_labels = list(unique_class_labels)
          assert len(unique_class_labels) == num_of_sub_dirs
  
          for unique_class_label in unique_class_labels:
              assert unique_class_label in class_label_strings
  
          for class_label_string in class_label_strings:
              assert class_label_string in unique_class_labels
  
          assert set(class_label_strings) == set(unique_class_labels)
  
          # Count
          labels_int = [x.class_label_int for x in p.augmentor_images]
          bins = np.bincount(labels_int)
          for bin in bins:
              assert bin == num_of_im_files
  
          labels = [x.class_label for x in p.augmentor_images]
          for sub_dir in sub_dirs:
              assert (
                  labels.count(os.path.basename(sub_dir))
                  == num_of_im_files
              )
  
      # Run the tests now, we will repeat later so it's been made into a func.
      run()
  
      # Add some extra images in places where they should not be and re-run the tests.
      temp_file_in_root_dir1 = tempfile.NamedTemporaryFile(
          dir=initial_temp_directory, suffix=".PNG", delete=False
      )
      temp_file_in_root_dir2 = tempfile.NamedTemporaryFile(
          dir=initial_temp_directory, suffix=".PNG", delete=False
      )
  
      # All tests should run exactly as before, those two files above should be ignored.
      run()
  
      # Sub directories in the sub directories should be ignored, so all tests should pass after
      # randomly placing a folder in any of these sud directories
      r1 = random.randint(0, len(sub_dirs) - 1)
      r2 = random.randint(0, len(sub_dirs) - 1)
      os.mkdir(
          os.path.join(
              initial_temp_directory, sub_dirs[r1], output_directory
          )
      )
      os.mkdir(
          os.path.join(
              initial_temp_directory, sub_dirs[r2], "ignore_me"
          )
      )
      temp_to_ignore = tempfile.NamedTemporaryFile(
          dir=os.path.join(
              initial_temp_directory, sub_dirs[r1], output_directory
          ),
          suffix=".JPEG",
          delete=False,
      )
      im = Image.fromarray(np.uint8(np.random.rand(80, 80, 3) * 255))
      im.save(temp_to_ignore.name, "JPEG")
      run()
  
      # Clean up
      for tmp_file in tmp_files:
          tmp_file.close()
  
      temp_file_in_root_dir1.close()
      temp_file_in_root_dir2.close()
      temp_to_ignore.close()
  
      shutil.rmtree(
          os.path.join(
              initial_temp_directory, sub_dirs[r1], output_directory
          )
      )
      shutil.rmtree(
          os.path.join(
              initial_temp_directory, sub_dirs[r2], "ignore_me"
          )
      )
  
      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)
  
imports: import pytest
  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
  from util_funcs import create_sub_folders
label_desc: Use image node_id 8 for calling a global function with example usage: test_class_image_scan() without return types