code: def _find_image_xrefs_container(
      pdf: Pdf,
      container: Object,
      pageno: int,
      include_xrefs: MutableSet[Xref],
      exclude_xrefs: MutableSet[Xref],
      pageno_for_xref: dict[Xref, int],
      depth: int = 0,
  ):
      """Find all image XRefs or Form XObject and add to the include/exclude sets."""
      if depth > 10:
          log.warning(
              "Recursion depth exceeded in _find_image_xrefs_page"
          )
          return
      try:
          xobjs = container.Resources.XObject
      except AttributeError:
          return
      for _imname, image in dict(xobjs).items():
          if image.objgen[1] != 0:
              continue  # Ignore images in an incremental PDF
          if Name.Subtype in image and image.Subtype == Name.Form:
              # Recurse into Form XObjects
              log.debug(
                  f"Recursing into Form XObject {_imname} in page {pageno}"
              )
              _find_image_xrefs_container(
                  pdf,
                  image,
                  pageno,
                  include_xrefs,
                  exclude_xrefs,
                  pageno_for_xref,
                  depth + 1,
              )
              continue
          xref = Xref(image.objgen[0])
          if Name.SMask in image:
              # Ignore soft masks
              smask_xref = Xref(image.SMask.objgen[0])
              exclude_xrefs.add(smask_xref)
              log.debug(
                  f"xref {smask_xref}: skipping image because it is an SMask"
              )
          include_xrefs.add(xref)
          log.debug(
              f"xref {xref}: treating as an optimization candidate"
          )
          if xref not in pageno_for_xref:
              pageno_for_xref[xref] = pageno
  
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 7 for calling a global function with example usage: _find_image_xrefs_container(pdf, container, pageno, include_xrefs, exclude_xrefs, pageno_for_xref, depth) without return types