code: def write_row_to_file(
      self, row: Dict[str, Any], file: "pyarrow.NativeFile"
  ):
      from PIL import Image
  
      image = Image.fromarray(row[self.column])
      buffer = io.BytesIO()
      image.save(buffer, format=self.file_format)
      file.write(buffer.getvalue())
  
file_path: ray/python/ray/data/datasource/image_datasink.py
imports: import io
  from typing import Any, Dict
  import pyarrow
  from ray.data.datasource.file_datasink import RowBasedFileDatasink
label_desc: Use image node_id 2 for calling the _ImageDatasink obj's underlying member method code with example usage: obj.write_row_to_file(row, file) without return types