code: def generate_pdfa(
      pdf_pages,
      pdfmark,
      output_file,
      context,
      pdf_version,
      pdfa_part,
      stop_on_soft_error,
  ):
      with patch(
          "ocrmypdf._exec.ghostscript.run_polling_stderr"
      ) as mock:
          mock.side_effect = fail_if_stoponerror
          ghostscript.generate_pdfa(
              pdf_pages=pdf_pages,
              pdfmark=pdfmark,
              output_file=output_file,
              context=context,
              pdf_version=pdf_version,
              pdfa_part=pdfa_part,
              progressbar_class=None,
              stop_on_soft_error=stop_on_soft_error,
          )
          mock.assert_called()
          return output_file
  
file_path: OCRmyPDF/tests/plugins/gs_render_soft_error.py
imports: from __future__ import annotations
  from pathlib import Path
  from subprocess import CalledProcessError
  from unittest.mock import patch
  from ocrmypdf import hookimpl
  from ocrmypdf.builtin_plugins import ghostscript
  from ocrmypdf.subprocess import run_polling_stderr
label_desc: Use image node_id 2 for calling a global function with example usage: generate_pdfa(pdf_pages, pdfmark, output_file, context, pdf_version, pdfa_part, stop_on_soft_error) and returns: output_file