code: def transcode_pngs(
      pdf: Pdf,
      images: Sequence[Xref],
      image_name_fn: Callable[[Path, Xref], Path],
      root: Path,
      options,
      executor: Executor,
  ) -> None:
      """Apply lossy transcoding to PNGs."""
      modified: MutableSet[Xref] = set()
      if options.optimize >= 2:
          png_quality = (
              max(10, options.png_quality - 10),
              min(100, options.png_quality + 10),
          )
  
          def pngquant_args():
              for xref in images:
                  log.debug(image_name_fn(root, xref))
                  yield (
                      image_name_fn(root, xref),
                      png_name(root, xref),
                      png_quality[0],
                      png_quality[1],
                  )
                  modified.add(xref)
  
          executor(
              use_threads=True,
              max_workers=options.jobs,
              progress_kwargs=dict(
                  desc="PNGs",
                  total=len(images),
                  unit="image",
                  disable=not options.progress_bar,
              ),
              task=pngquant.quantize,
              task_arguments=pngquant_args(),
          )
  
      for xref in modified:
          filename = png_name(root, xref)
          _transcode_png(pdf, filename, xref)
  
imports: from __future__ import annotations
  import logging
  import sys
  import tempfile
  import threading
  from collections import defaultdict
  from collections.abc import Iterator, MutableSet, Sequence
  from os import fspath
  from pathlib import Path
  from typing import Any, Callable, NamedTuple, NewType
  from warnings import warn
  from zlib import compress
  import img2pdf
  from pikepdf import Dictionary, Name, Object, ObjectStreamMode, Pdf, PdfError, PdfImage, Stream, UnsupportedImageTypeError
  from PIL import Image
  from ocrmypdf._concurrent import Executor, SerialExecutor
  from ocrmypdf._exec import jbig2enc, pngquant
  from ocrmypdf._jobcontext import PdfContext
  from ocrmypdf._progressbar import ProgressBar
  from ocrmypdf.exceptions import OutputFileAccessError
  from ocrmypdf.helpers import IMG2PDF_KWARGS, safe_symlink
label_desc: Use image node_id 20 for calling a global function with example usage: transcode_pngs(pdf, images, image_name_fn, root, options, executor) without return types