code: def test_image_data_generator_flow(all_test_images, tmpdir):
      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)
          dsize = images.shape[0]
          generator = image_data_generator.ImageDataGenerator(
              featurewise_center=True,
              samplewise_center=True,
              featurewise_std_normalization=True,
              samplewise_std_normalization=True,
              zca_whitening=True,
              rotation_range=90.0,
              width_shift_range=0.1,
              height_shift_range=0.1,
              shear_range=0.5,
              zoom_range=0.2,
              channel_shift_range=0.0,
              brightness_range=(1, 5),
              fill_mode="nearest",
              cval=0.5,
              horizontal_flip=True,
              vertical_flip=True,
              interpolation_order=1,
          )
  
          generator.flow(
              images,
              np.arange(images.shape[0]),
              shuffle=False,
              save_to_dir=str(tmpdir),
              batch_size=3,
          )
  
          generator.flow(
              images,
              np.arange(images.shape[0]),
              shuffle=False,
              sample_weight=np.arange(images.shape[0]) + 1,
              save_to_dir=str(tmpdir),
              batch_size=3,
          )
  
          # Test with `shuffle=True`
          generator.flow(
              images,
              np.arange(images.shape[0]),
              shuffle=True,
              save_to_dir=str(tmpdir),
              batch_size=3,
              seed=42,
          )
  
          # Test without y
          generator.flow(
              images,
              None,
              shuffle=True,
              save_to_dir=str(tmpdir),
              batch_size=3,
          )
  
          # Test with a single miscellaneous input data array
          x_misc1 = np.random.random(dsize)
          generator.flow(
              (images, x_misc1),
              np.arange(dsize),
              shuffle=False,
              batch_size=2,
          )
  
          # Test with two miscellaneous inputs
          x_misc2 = np.random.random((dsize, 3, 3))
          generator.flow(
              (images, [x_misc1, x_misc2]),
              np.arange(dsize),
              shuffle=False,
              batch_size=2,
          )
  
          # Test cases with `y = None`
          generator.flow(images, None, batch_size=3)
          generator.flow(
              (images, x_misc1), None, batch_size=3, shuffle=False
          )
          generator.flow(
              (images, [x_misc1, x_misc2]),
              None,
              batch_size=3,
              shuffle=False,
          )
          generator = image_data_generator.ImageDataGenerator(
              validation_split=0.2
          )
          generator.flow(images, batch_size=3)
  
          # Test some failure cases:
          x_misc_err = np.random.random((dsize + 1, 3, 3))
          with pytest.raises(ValueError) as e_info:
              generator.flow(
                  (images, x_misc_err), np.arange(dsize), batch_size=3
              )
          assert str(e_info.value).find("All of the arrays in") != -1
  
          with pytest.raises(ValueError) as e_info:
              generator.flow(
                  (images, x_misc1), np.arange(dsize + 1), batch_size=3
              )
          assert (
              str(e_info.value).find(
                  "`x` (images tensor) and `y` (labels) "
              )
              != -1
          )
  
          # Test `flow` behavior as Sequence
          generator.flow(
              images,
              np.arange(images.shape[0]),
              shuffle=False,
              save_to_dir=str(tmpdir),
              batch_size=3,
          )
  
          # Test with `shuffle=True`
          generator.flow(
              images,
              np.arange(images.shape[0]),
              shuffle=True,
              save_to_dir=str(tmpdir),
              batch_size=3,
              seed=123,
          )
  
      # test order_interpolation
      labels = np.array(
          [
              [2, 2, 0, 2, 2],
              [1, 3, 2, 3, 1],
              [2, 1, 0, 1, 2],
              [3, 1, 0, 2, 0],
              [3, 1, 3, 2, 1],
          ]
      )
  
      label_generator = image_data_generator.ImageDataGenerator(
          rotation_range=90.0, interpolation_order=0
      )
      label_generator.flow(
          x=labels[np.newaxis, ..., np.newaxis], seed=123
      )
  
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 7 for calling a global function with example usage: test_image_data_generator_flow(all_test_images, tmpdir) without return types