code: def test_write_png(img_path, tmpdir):
      pil_image = Image.open(img_path)
      img_pil = torch.from_numpy(np.array(pil_image))
      img_pil = img_pil.permute(2, 0, 1)
  
      filename, _ = os.path.splitext(os.path.basename(img_path))
      torch_png = os.path.join(tmpdir, f"{filename}_torch.png")
      write_png(img_pil, torch_png, compression_level=6)
      saved_image = torch.from_numpy(np.array(Image.open(torch_png)))
      saved_image = saved_image.permute(2, 0, 1)
  
      assert_equal(img_pil, saved_image)
  
imports: import glob
  import io
  import os
  import sys
  from pathlib import Path
  import numpy
  import pytest
  import torch
  import torchvision.transforms.functional
  from common_utils import assert_equal, needs_cuda
  from PIL import __version__, Image
  from torchvision.io.image import _read_png_16, decode_image, decode_jpeg, decode_png, encode_jpeg, encode_png, ImageReadMode, read_file, read_image, write_file, write_jpeg, write_png
label_desc: Use image node_id 13 for calling a global function with example usage: test_write_png(img_path, tmpdir) without return types