code: def test_write_output_shape(self):
      with tempfile.TemporaryDirectory() as out_dir:
          image_name = os.path.join(out_dir, "test.png")
          img = np.random.rand(2, 2, 3)
          writer_obj = PILWriter(output_dtype=np.uint8)
          writer_obj.set_data_array(img, channel_dim=-1)
          writer_obj.set_metadata({"spatial_shape": (4, 4)}, scale=255)
          writer_obj.write(image_name, format="PNG")
          out = np.asarray(Image.open(image_name))
          np.testing.assert_allclose(out.shape, (4, 4, 3))
  
file_path: MONAI/tests/test_png_rw.py
imports: from __future__ import annotations
  import os
  import tempfile
  import unittest
  import numpy
  from PIL import Image
  from monai.data.image_writer import PILWriter
label_desc: Use image node_id 6 for calling the TestPngWrite obj's underlying member method code with example usage: obj.test_write_output_shape() without return types