code: def test_rasterize_size(francais, outdir):
      path, pdf = francais
      page_size_pts = (
          pdf.pages[0].mediabox[2],
          pdf.pages[0].mediabox[3],
      )
      assert pdf.pages[0].mediabox[0] == pdf.pages[0].mediabox[1] == 0
      page_size = (
          page_size_pts[0] / Decimal(72),
          page_size_pts[1] / Decimal(72),
      )
      target_size = Decimal("50.0"), Decimal("30.0")
      forced_dpi = Resolution(42.0, 4242.0)
  
      rasterize_pdf(
          path,
          outdir / "out.png",
          raster_device="pngmono",
          raster_dpi=Resolution(
              target_size[0] / page_size[0],
              target_size[1] / page_size[1],
          ),
          page_dpi=forced_dpi,
      )
  
      with Image.open(outdir / "out.png") as im:
          assert im.size == target_size
          assert im.info["dpi"] == forced_dpi
  
imports: from __future__ import annotations
  import logging
  import secrets
  import subprocess
  from decimal import Decimal
  from unittest.mock import patch
  import pikepdf
  import pytest
  from PIL import Image, UnidentifiedImageError
  from ocrmypdf._exec.ghostscript import DuplicateFilter, rasterize_pdf
  from ocrmypdf.exceptions import ColorConversionNeededError, ExitCode
  from ocrmypdf.helpers import Resolution
  from .conftest import check_ocrmypdf, run_ocrmypdf_api
label_desc: Use image node_id 2 for calling a global function with example usage: test_rasterize_size(francais, outdir) without return types