code: def write_row_to_file(
      self, row: Dict[str, Any], file: pyarrow.NativeFile
  ):
      import io
      from PIL import Image
  
      # PIL can't write to a NativeFile, so we have to write to a buffer first.
      image = Image.fromarray(row[self.column])
      buffer = io.BytesIO()
      image.save(buffer, format=self.file_format)
      file.write(buffer.getvalue())
  
file_path: ray/doc/source/data/doc_code/custom_datasource_example.py
imports: from typing import Iterator, Union, List
  import pyarrow
  from ray.data.block import Block
  from ray.data.datasource import FileBasedDatasource
  import ray
  from typing import Any, Dict
  import pyarrow
  from ray.data.datasource 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