code: def test_directory_iterator_with_validation_split(
      all_test_images, validation_split, num_training
  ):
      num_classes = 2
      tmp_folder = tempfile.mkdtemp(prefix="test_images")
  
      # create folders and subfolders
      paths = []
      for cl in range(num_classes):
          class_directory = "class-{}".format(cl)
          classpaths = [
              class_directory,
              os.path.join(class_directory, "subfolder-1"),
              os.path.join(class_directory, "subfolder-2"),
              os.path.join(
                  class_directory, "subfolder-1", "sub-subfolder"
              ),
          ]
          for path in classpaths:
              os.mkdir(os.path.join(tmp_folder, path))
          paths.append(classpaths)
  
      # save the images in the paths
      count = 0
      filenames = []
      for test_images in all_test_images:
          for im in test_images:
              # rotate image class
              im_class = count % num_classes
              # rotate subfolders
              classpaths = paths[im_class]
              filename = os.path.join(
                  classpaths[count % len(classpaths)],
                  "image-{}.png".format(count),
              )
              filenames.append(filename)
              im.save(os.path.join(tmp_folder, filename))
              count += 1
  
      # create iterator
      generator = image_data_generator.ImageDataGenerator(
          validation_split=validation_split
      )
  
      with pytest.raises(ValueError):
          generator.flow_from_directory(tmp_folder, subset="foo")
  
      train_iterator = generator.flow_from_directory(
          tmp_folder, subset="training"
      )
      assert train_iterator.samples == num_training
  
      valid_iterator = generator.flow_from_directory(
          tmp_folder, subset="validation"
      )
      assert valid_iterator.samples == count - num_training
  
      # check number of classes and images
      assert len(train_iterator.class_indices) == num_classes
      assert len(train_iterator.classes) == num_training
      assert (
          len(set(train_iterator.filenames) & set(filenames))
          == num_training
      )
  
      shutil.rmtree(tmp_folder)
  
file_path: keras-preprocessing/tests/image/directory_iterator_test.py
imports: import os
  import shutil
  import tempfile
  import numpy
  import pytest
  from PIL import Image
  from keras_preprocessing.image import image_data_generator
label_desc: Use image node_id 4 for calling a global function with example usage: test_directory_iterator_with_validation_split(all_test_images, validation_split, num_training) without return types