code: def test_multipage_keep_empty(tmp_path):
      os.chdir(tmp_path)
  
      # test empty pdf files
  
      # an empty pdf is left behind with keep_empty unset
      with pytest.warns(mpl.MatplotlibDeprecationWarning), PdfPages(
          "a.pdf"
      ) as pdf:
          pass
      assert os.path.exists("a.pdf")
  
      # an empty pdf is left behind with keep_empty=True
      with pytest.warns(mpl.MatplotlibDeprecationWarning), PdfPages(
          "b.pdf", keep_empty=True
      ) as pdf:
          pass
      assert os.path.exists("b.pdf")
  
      # an empty pdf deletes itself afterwards with keep_empty=False
      with PdfPages("c.pdf", keep_empty=False) as pdf:
          pass
      assert not os.path.exists("c.pdf")
  
      # test pdf files with content, they should never be deleted
  
      # a non-empty pdf is left behind with keep_empty unset
      with PdfPages("d.pdf") as pdf:
          pdf.savefig(plt.figure())
      assert os.path.exists("d.pdf")
  
      # a non-empty pdf is left behind with keep_empty=True
      with pytest.warns(mpl.MatplotlibDeprecationWarning), PdfPages(
          "e.pdf", keep_empty=True
      ) as pdf:
          pdf.savefig(plt.figure())
      assert os.path.exists("e.pdf")
  
      # a non-empty pdf is left behind with keep_empty=False
      with PdfPages("f.pdf", keep_empty=False) as pdf:
          pdf.savefig(plt.figure())
      assert os.path.exists("f.pdf")
  
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 5 for calling a global function with example usage: test_multipage_keep_empty(tmp_path) without return types