class_docstr: Write image data into files on disk using pillow.
  
  It's based on the Image module in PIL library:
  https://pillow.readthedocs.io/en/stable/reference/Image.html
  
  .. code-block:: python
  
      import numpy as np
      from monai.data import PILWriter
  
      np_data = np.arange(48).reshape(3, 4, 4)
      writer = PILWriter(np.uint8)
      writer.set_data_array(np_data, channel_dim=0)
      writer.write("test1.png", verbose=True)
class_docstr_tok: ["Write","image","data","into","files","on","disk","using","pillow",".","It","'s","based","on","the","Image","module","in","PIL","library",":","https",":","\/\/pillow.readthedocs.io\/en\/stable\/reference\/Image.html","..","code-block",":",":","python","import","numpy","as","np","from","monai.data","import","PILWriter","np_data","=","np.arange","(","48",")",".reshape","(","3",",","4",",","4",")","writer","=","PILWriter","(","np.uint8",")","writer.set_data_array","(","np_data",",","channel_dim=0",")","writer.write","(","``","test1.png","''",",","verbose=True",")"]
docstr: Create a PIL image object from ``self.create_backend_obj(self.obj, ...)`` and call ``save``.
  
  Args:
      filename: filename or PathLike object.
      verbose: if ``True``, log the progress.
      kwargs: optional keyword arguments passed to ``self.create_backend_obj``
          currently support ``reverse_indexing``, ``image_mode``, defaulting to ``True``, ``None`` respectively.
  
  See also:
  
      - https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.save
docstr_tok: ["Create","a","PIL","image","object","from","``","self.create_backend_obj","(","self.obj",",","...",")","``","and","call","``","save","``",".","Args",":","filename",":","filename","or","PathLike","object",".","verbose",":","if","``","True","``",",","log","the","progress",".","kwargs",":","optional","keyword","arguments","passed","to","``","self.create_backend_obj","``","currently","support","``","reverse_indexing","``",",","``","image_mode","``",",","defaulting","to","``","True","``",",","``","None","``","respectively",".","See","also",":","-","https",":","\/\/pillow.readthedocs.io\/en\/stable\/reference\/Image.html","#","PIL.Image.Image.save"]
code: def write(self, filename: PathLike, verbose: bool = False, **kwargs):
      """
      Create a PIL image object from ``self.create_backend_obj(self.obj, ...)`` and call ``save``.
  
      Args:
          filename: filename or PathLike object.
          verbose: if ``True``, log the progress.
          kwargs: optional keyword arguments passed to ``self.create_backend_obj``
              currently support ``reverse_indexing``, ``image_mode``, defaulting to ``True``, ``None`` respectively.
  
      See also:
  
          - https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.save
      """
      super().write(filename, verbose=verbose)
      self.data_obj = self.create_backend_obj(
          data_array=self.data_obj,
          dtype=self.output_dtype,
          reverse_indexing=kwargs.pop("reverse_indexing", True),
          image_mode=kwargs.pop("image_mode", None),
          scale=self.scale,
          **kwargs,
      )
      self.data_obj.save(filename, **kwargs)
  
imports: from __future__ import annotations
  from collections.abc import Mapping, Sequence
  from typing import TYPE_CHECKING, Any, cast
  import numpy
  from monai.apps.utils import get_logger
  from monai.config import DtypeLike, NdarrayOrTensor, PathLike
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import affine_to_spacing, ensure_tuple, ensure_tuple_rep, orientation_ras_lps, to_affine_nd
  from monai.transforms.spatial.array import Resize, SpatialResample
  from monai.transforms.utils_pytorch_numpy_unification import ascontiguousarray, moveaxis
  from monai.utils import GridSampleMode, GridSamplePadMode, InterpolateMode, MetaKeys, OptionalImportError, SpaceKeys, convert_data_type, convert_to_tensor, get_equivalent_dtype, look_up_option, optional_import, require_pkg
label_desc: Use image node_id 4 for calling the PILWriter obj's underlying member method code with example usage: obj.write(filename, verbose) without return types