code: def test_xml_metadata_preserved(
      libxmp_file_to_dict, test_file, output_type, resources, outpdf
  ):
      input_file = resources / test_file
  
      before = libxmp_file_to_dict(str(input_file))
  
      check_ocrmypdf(
          input_file,
          outpdf,
          "--output-type",
          output_type,
          "--skip-text",
          "--plugin",
          "tests/plugins/tesseract_noop.py",
      )
  
      after = libxmp_file_to_dict(str(outpdf))
  
      equal_properties = [
          "dc:contributor",
          "dc:coverage",
          "dc:creator",
          "dc:description",
          "dc:format",
          "dc:identifier",
          "dc:language",
          "dc:publisher",
          "dc:relation",
          "dc:rights",
          "dc:source",
          "dc:subject",
          "dc:title",
          "dc:type",
          "pdf:keywords",
      ]
      acquired_properties = ["dc:format"]
  
      # Cleanup messy data structure
      # Top level is key-value mapping of namespaces to keys under namespace,
      # so we put everything in the same namespace
      def unify_namespaces(xmpdict):
          for entries in xmpdict.values():
              yield from entries
  
      # Now we have a list of (key, value, {infodict}). We don't care about
      # infodict. Just flatten to keys and values
      def keyval_from_tuple(list_of_tuples):
          for k, v, *_ in list_of_tuples:
              yield k, v
  
      before = dict(keyval_from_tuple(unify_namespaces(before)))
      after = dict(keyval_from_tuple(unify_namespaces(after)))
  
      for prop in equal_properties:
          if prop in before:
              assert prop in after, f"{prop} dropped from xmp"
              assert before[prop] == after[prop]
  
          # libxmp presents multivalued entries (e.g. dc:title) as:
          # 'dc:title': '' <- there's a title
          # 'dc:title[1]: 'The Title' <- the actual title
          # 'dc:title[1]/?xml:lang': 'x-default' <- language info
          propidx = f"{prop}[1]"
          if propidx in before:
              assert (
                  after.get(propidx) == before[propidx]
                  or after.get(prop) == before[propidx]
              )
  
          if prop in after and prop not in before:
              assert prop in acquired_properties, (
                  f"acquired unexpected property {prop} with value "
                  f"{after.get(propidx) or after.get(prop)}"
              )
  
imports: from __future__ import annotations
  import datetime
  import warnings
  from datetime import timezone
  from shutil import copyfile
  import pikepdf
  import pytest
  from packaging.version import Version
  from pikepdf.models.metadata import decode_pdf_date
  from ocrmypdf._exec import ghostscript
  from ocrmypdf._jobcontext import PdfContext
  from ocrmypdf._metadata import metadata_fixup
  from ocrmypdf._pipeline import convert_to_pdfa
  from ocrmypdf._plugin_manager import get_parser_options_plugins, get_plugin_manager
  from ocrmypdf.exceptions import ExitCode
  from ocrmypdf.pdfa import file_claims_pdfa, generate_pdfa_ps
  from ocrmypdf.pdfinfo import PdfInfo
  from .conftest import check_ocrmypdf, run_ocrmypdf, run_ocrmypdf_api
label_desc: Use image node_id 9 for calling a global function with example usage: test_xml_metadata_preserved(libxmp_file_to_dict, test_file, output_type, resources, outpdf) without return types