code: def test_sanity(tmp_path):
      for mode in ("RGB", "RGBA", "L", "P", "1"):
          src = hopper(mode)
          data = ImageQt.toqimage(src)
  
          assert isinstance(data, QImage)
          assert not data.isNull()
  
          # reload directly from the qimage
          rt = ImageQt.fromqimage(data)
          if mode in ("L", "P", "1"):
              assert_image_equal(rt, src.convert("RGB"))
          else:
              assert_image_equal(rt, src)
  
          if mode == "1":
              # BW appears to not save correctly on QT4 and QT5
              # kicks out errors on console:
              #     libpng warning: Invalid color type/bit depth combination
              #                     in IHDR
              #     libpng error: Invalid IHDR data
              continue
  
          # Test saving the file
          tempfile = str(tmp_path / f"temp_{mode}.png")
          data.save(tempfile)
  
          # Check that it actually worked.
          assert_image_equal_tofile(src, tempfile)
  
label_desc: Use image node_id 1 for calling a global function with example usage: test_sanity(tmp_path) without return types