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
  from io import BytesIO
  import os
  import shutil
  import numpy
  from packaging.version import parse
  import pytest
  import matplotlib
  import matplotlib.pyplot
  from matplotlib.testing import _has_tex_package, _check_for_pgf
  from matplotlib.testing.exceptions import ImageComparisonFailure
  from matplotlib.testing.compare import compare_images
  from matplotlib.backends.backend_pgf import PdfPages
  from matplotlib.testing.decorators import _image_directories, check_figures_equal, image_comparison
  from matplotlib.testing._markers import needs_ghostscript, needs_pgf_lualatex, needs_pgf_pdflatex, needs_pgf_xelatex
label_desc: Use image node_id 12 for calling a global function with example usage: test_multipage_keep_empty(tmp_path) without return types