code: def test_invalid_metadata():
      fig, ax = plt.subplots()
  
      with pytest.warns(
          UserWarning, match="Unknown infodict keyword: 'foobar'."
      ):
          fig.savefig(
              io.BytesIO(), format="pdf", metadata={"foobar": "invalid"}
          )
  
      with pytest.warns(
          UserWarning, match="not an instance of datetime.datetime."
      ):
          fig.savefig(
              io.BytesIO(),
              format="pdf",
              metadata={"ModDate": "1968-08-01"},
          )
  
      with pytest.warns(
          UserWarning, match='not one of {"True", "False", "Unknown"}'
      ):
          fig.savefig(
              io.BytesIO(), format="pdf", metadata={"Trapped": "foo"}
          )
  
      with pytest.warns(UserWarning, match="not an instance of str."):
          fig.savefig(
              io.BytesIO(), format="pdf", metadata={"Title": 1234}
          )
  
imports: import datetime
  import decimal
  import io
  import os
  from pathlib import Path
  import numpy
  import pytest
  import matplotlib
  from matplotlib import pyplot, rcParams, font_manager
  from matplotlib.cbook import _get_data_path
  from matplotlib.ft2font import FT2Font
  from matplotlib.font_manager import findfont, FontProperties
  from matplotlib.backends._backend_pdf_ps import get_glyphs_subset
  from matplotlib.backends.backend_pdf import PdfPages
  from matplotlib.patches import Rectangle
  from matplotlib.testing.decorators import check_figures_equal, image_comparison
  from matplotlib.testing._markers import needs_usetex
label_desc: Use image node_id 9 for calling a global function with example usage: test_invalid_metadata() without return types