code: def generate_images(
      num_images: int,
      sizes: List[Tuple[int, int]],
      modes: List[str],
      formats: List[str],
  ) -> str:
      dimensions = []
      for mode in modes:
          if mode in ["1", "L", "P"]:
              dimension = 1
          elif mode in ["RGB", "YCbCr", "LAB", "HSV"]:
              dimension = 3
          elif mode in ["RGBA", "CMYK", "I", "F"]:
              dimension = 4
          else:
              raise ValueError(f"Found unknown image mode: {mode}.")
          dimensions.append(dimension)
  
      images_dir = tempfile.mkdtemp()
  
      for image_idx in range(num_images):
          size = random.choice(sizes)
          file_format = random.choice(formats)
          mode_idx = random.randrange(len(modes))
          mode = modes[mode_idx]
          dimension = dimensions[mode_idx]
  
          width, height = size
          file_name = f"{images_dir}/{image_idx}.{file_format}"
          pixels_per_dimension = []
          for _ in range(dimension):
              pixels = os.urandom(width * height)
              pixels_per_dimension.append(pixels)
  
          image = Image.new(mode, size)
          if len(pixels_per_dimension) == 1:
              image.putdata(pixels_per_dimension[0])
          else:
              image.putdata(list(zip(*pixels_per_dimension)))
          image.save(file_name)
  
      return images_dir
  
file_path: ray/release/nightly_tests/dataset/read_images_benchmark.py
imports: import argparse
  import os
  import random
  import shutil
  import tempfile
  from typing import List, Tuple
  from PIL import Image
  import ray
  from benchmark import Benchmark
label_desc: Use image node_id 3 for calling a global function with example usage: generate_images(num_images, sizes, modes, formats) and returns: images_dir