code: def test_dataframe_iterator_with_validation_split(
      all_test_images, validation_split, num_training, tmpdir
  ):
      num_classes = 2
  
      # save the images in the tmpdir
      count = 0
      filenames = []
      filenames_without = []
      for test_images in all_test_images:
          for im in test_images:
              filename = "image-{}.png".format(count)
              filename_without = "image-{}".format(count)
              filenames.append(filename)
              filenames_without.append(filename_without)
              im.save(str(tmpdir / filename))
              count += 1
  
      df = pd.DataFrame(
          {
              "filename": filenames,
              "class": [str(random.randint(0, 1)) for _ in filenames],
          }
      )
      # create iterator
      generator = image_data_generator.ImageDataGenerator(
          validation_split=validation_split
      )
      df_sparse_iterator = generator.flow_from_dataframe(
          df, str(tmpdir), class_mode="sparse"
      )
      if np.isnan(next(df_sparse_iterator)[:][1]).any():
          raise ValueError("Invalid values.")
  
      with pytest.raises(ValueError):
          generator.flow_from_dataframe(df, tmpdir, subset="foo")
  
      train_iterator = generator.flow_from_dataframe(
          df, str(tmpdir), subset="training"
      )
      assert train_iterator.samples == num_training
  
      valid_iterator = generator.flow_from_dataframe(
          df, str(tmpdir), 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
      )
  
imports: import os
  import random
  import shutil
  import numpy
  import pandas
  import pytest
  from PIL import Image
  from keras_preprocessing.image import dataframe_iterator, image_data_generator
label_desc: Use image node_id 9 for calling a global function with example usage: test_dataframe_iterator_with_validation_split(all_test_images, validation_split, num_training, tmpdir) without return types