code: def test_image_data_generator_with_validation_split(all_test_images):
      for test_images in all_test_images:
          img_list = []
          for im in test_images:
              img_list.append(utils.img_to_array(im)[None, ...])
  
          images = np.vstack(img_list)
          labels = np.concatenate(
              [
                  np.zeros((int(len(images) / 2),)),
                  np.ones((int(len(images) / 2),)),
              ]
          )
          generator = image_data_generator.ImageDataGenerator(
              validation_split=0.5
          )
  
          # training and validation sets would have different
          # number of classes, because labels are sorted
          with pytest.raises(
              ValueError,
              match="Training and validation subsets "
              "have different number of classes after "
              "the split.*",
          ):
              generator.flow(
                  images,
                  labels,
                  shuffle=False,
                  batch_size=10,
                  subset="validation",
              )
  
          # test non categorical labels with validation split
          generator.flow(
              images,
              labels,
              shuffle=False,
              batch_size=10,
              ignore_class_split=True,
              subset="validation",
          )
  
          labels = np.concatenate(
              [
                  np.zeros((int(len(images) / 4),)),
                  np.ones((int(len(images) / 4),)),
                  np.zeros((int(len(images) / 4),)),
                  np.ones((int(len(images) / 4),)),
              ]
          )
  
          seq = generator.flow(
              images,
              labels,
              shuffle=False,
              batch_size=10,
              subset="validation",
          )
  
          x, y = seq[0]
          assert 2 == len(np.unique(y))
  
          seq = generator.flow(
              images,
              labels,
              shuffle=False,
              batch_size=10,
              subset="training",
          )
          x2, y2 = seq[0]
          assert 2 == len(np.unique(y2))
  
          with pytest.raises(ValueError):
              generator.flow(
                  images,
                  np.arange(images.shape[0]),
                  shuffle=False,
                  batch_size=3,
                  subset="foo",
              )
  
file_path: keras-preprocessing/tests/image/image_data_generator_test.py
imports: import numpy
  import pytest
  from PIL import Image
  from keras_preprocessing.image import image_data_generator, utils
label_desc: Use image node_id 3 for calling a global function with example usage: test_image_data_generator_with_validation_split(all_test_images) without return types