code: def helper_save_as_pdf(tmp_path, mode, **kwargs):
      # Arrange
      im = hopper(mode)
      outfile = str(tmp_path / ("temp_" + mode + ".pdf"))
  
      # Act
      im.save(outfile, **kwargs)
  
      # Assert
      assert os.path.isfile(outfile)
      assert os.path.getsize(outfile) > 0
      with PdfParser.PdfParser(outfile) as pdf:
          if kwargs.get("append_images", False) or kwargs.get(
              "append", False
          ):
              assert len(pdf.pages) > 1
          else:
              assert len(pdf.pages) > 0
      with open(outfile, "rb") as fp:
          contents = fp.read()
      size = tuple(
          float(d)
          for d in contents.split(b"/MediaBox [ 0 0 ")[1]
          .split(b"]")[0]
          .split()
      )
      assert im.size == size
  
      return outfile
  
imports: import io
  import os
  import os.path
  import tempfile
  import time
  import pytest
  from PIL import Image, PdfParser
  from .helper import hopper, mark_if_feature_version
label_desc: Use image node_id 1 for calling a global function with example usage: helper_save_as_pdf(tmp_path, mode) and returns: outfile