code: def test_encode_png_errors():
      with pytest.raises(
          RuntimeError, match="Input tensor dtype should be uint8"
      ):
          encode_png(torch.empty((3, 100, 100), dtype=torch.float32))
  
      with pytest.raises(
          RuntimeError,
          match="Compression level should be between 0 and 9",
      ):
          encode_png(
              torch.empty((3, 100, 100), dtype=torch.uint8),
              compression_level=-1,
          )
  
      with pytest.raises(
          RuntimeError,
          match="Compression level should be between 0 and 9",
      ):
          encode_png(
              torch.empty((3, 100, 100), dtype=torch.uint8),
              compression_level=10,
          )
  
      with pytest.raises(
          RuntimeError,
          match="The number of channels should be 1 or 3, got: 5",
      ):
          encode_png(torch.empty((5, 100, 100), dtype=torch.uint8))
  
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 12 for calling a global function with example usage: test_encode_png_errors() without return types