code: def test_write_metadata(tmp_path):
      """Test metadata writing through the python code"""
      with Image.open("Tests/images/hopper.tif") as img:
          f = str(tmp_path / "temp.tiff")
          img.save(f, tiffinfo=img.tag)
  
          original = img.tag_v2.named()
  
      with Image.open(f) as loaded:
          reloaded = loaded.tag_v2.named()
  
      ignored = [
          "StripByteCounts",
          "RowsPerStrip",
          "PageNumber",
          "StripOffsets",
      ]
  
      for tag, value in reloaded.items():
          if tag in ignored:
              continue
          if isinstance(original[tag], tuple) and isinstance(
              original[tag][0], IFDRational
          ):
              # Need to compare element by element in the tuple,
              # not comparing tuples of object references
              assert_deep_equal(
                  original[tag],
                  value,
                  f"{tag} didn't roundtrip, {original[tag]}, {value}",
              )
          else:
              assert (
                  original[tag] == value
              ), f"{tag} didn't roundtrip, {original[tag]}, {value}"
  
      for tag, value in original.items():
          if tag not in ignored:
              assert value == reloaded[tag], f"{tag} didn't roundtrip"
  
imports: import io
  import struct
  import pytest
  from PIL import Image, TiffImagePlugin, TiffTags
  from PIL.TiffImagePlugin import IFDRational
  from .helper import assert_deep_equal, hopper
label_desc: Use image node_id 3 for calling a global function with example usage: test_write_metadata(tmp_path) without return types