code: def preprocess_mosaic(input_dir, output_dir):
      print("Writing to mosaic...")
      ds = ray.data.read_images(input_dir, mode="RGB")
      it = ds.iter_rows()
  
      columns = {"image": "pil", "label": "int"}
      # If reading from local disk, should turn off compression and use
      # streaming.LocalDataset.
      # If uploading to S3, turn on compression (e.g., compression="snappy") and
      # streaming.StreamingDataset.
      with streaming.MDSWriter(
          out=output_dir, columns=columns, compression=None
      ) as out:
          for i, img in enumerate(it):
              img = PIL.Image.fromarray(img["image"])
              out.write(
                  {
                      "image": img,
                      "label": 0,
                  }
              )
              if i % 10 == 0:
                  print(f"Wrote {i} images.")
  
imports: import os
  import PIL
  import streaming
  import ray
label_desc: Use image node_id 1 for calling a global function with example usage: preprocess_mosaic(input_dir, output_dir) without return types