code: def test_rotate_page_level(
      image_angle, page_angle, resources, outdir, caplog
  ):
      def make_rotate_test(prefix, image_angle, page_angle):
          memimg = BytesIO()
          with Image.open(fspath(resources / "typewriter.png")) as im:
              if image_angle != 0:
                  ccw_angle = -image_angle % 360
                  im = im.transpose(
                      getattr(Image.Transpose, f"ROTATE_{ccw_angle}")
                  )
              im.save(memimg, format="PNG")
          memimg.seek(0)
          mempdf = BytesIO()
          img2pdf.convert(
              memimg.read(),
              layout_fun=img2pdf.get_fixed_dpi_layout_fun((200, 200)),
              outputstream=mempdf,
              **IMG2PDF_KWARGS,
          )
          mempdf.seek(0)
          with pikepdf.open(mempdf) as pdf:
              pdf.pages[0].Rotate = page_angle
              target = (
                  outdir / f"{prefix}_{image_angle}_{page_angle}.pdf"
              )
              pdf.save(target)
              return target
  
      reference = make_rotate_test("ref", 0, 0)
      test = make_rotate_test("test", image_angle, page_angle)
      out = test.with_suffix(".out.pdf")
  
      exitcode = run_ocrmypdf_api(
          test,
          out,
          "-O0",
          "--rotate-pages",
          "--rotate-pages-threshold",
          "0.001",
      )
      assert exitcode == 0, caplog.text
  
      assert (
          compare_images_monochrome(outdir, reference, 1, out, 1) > 0.2
      )
  
imports: from __future__ import annotations
  import operator
  import warnings
  from io import BytesIO
  from math import cos, pi, sin
  from os import fspath
  import img2pdf
  import pikepdf
  import pytest
  from PIL import Image, ImageChops
  from reportlab.pdfgen.canvas import Canvas
  from ocrmypdf._exec import ghostscript
  from ocrmypdf._plugin_manager import get_plugin_manager
  from ocrmypdf.helpers import IMG2PDF_KWARGS, Resolution
  from ocrmypdf.pdfinfo import PdfInfo
  from .conftest import check_ocrmypdf, run_ocrmypdf_api
label_desc: Use image node_id 7 for calling a global function with example usage: test_rotate_page_level(image_angle, page_angle, resources, outdir, caplog) and returns: target