code: def log_listener(q: Queue):
      """Listen to the worker processes and forward the messages to logging.
  
      For simplicity this is a thread rather than a process. Only one process
      should actually write to sys.stderr or whatever we're using, so if this is
      made into a process the main application needs to be directed to it.
  
      See:
      https://docs.python.org/3/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes
      """
      while True:
          try:
              record = q.get()
              if record is None:
                  break
              logger = logging.getLogger(record.name)
              logger.handle(record)
          except Exception:  # pylint: disable=broad-except
              import traceback  # pylint: disable=import-outside-toplevel
  
              print("Logging problem", file=sys.stderr)
              traceback.print_exc(file=sys.stderr)
  
imports: from __future__ import annotations
  import logging
  import logging.handlers
  import multiprocessing
  import os
  import queue
  import signal
  import sys
  import threading
  from collections.abc import Iterable
  from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed
  from contextlib import suppress
  from typing import Callable, Union
  from rich.console import Console
  from ocrmypdf import Executor, hookimpl
  from ocrmypdf._logging import RichLoggingHandler
  from ocrmypdf._progressbar import RichProgressBar
  from ocrmypdf.exceptions import InputFileError
  from ocrmypdf.helpers import remove_all_log_handlers
label_desc: Use image node_id 1 for calling a global function with example usage: log_listener(q) without return types