code: def process_only_nodes(document: Node, tags: Tags) -> None:
      """Filter ``only`` nodes which do not match *tags*."""
      for node in document.findall(addnodes.only):
          if _only_node_keep_children(node, tags):
              node.replace_self(node.children or nodes.comment())
          else:
              # A comment on the comment() nodes being inserted: replacing by [] would
              # result in a "Losing ids" exception if there is a target node before
              # the only node, so we make sure docutils can transfer the id to
              # something, even if it's just a comment and will lose the id anyway...
              node.replace_self(nodes.comment())
  
imports: from __future__ import annotations
  import contextlib
  import re
  import unicodedata
  from typing import TYPE_CHECKING, Any, Callable
  from docutils import nodes
  from sphinx import addnodes
  from sphinx.locale import __
  from sphinx.util import logging
label_desc: Use image node_id 24 for calling a global function with example usage: process_only_nodes(document, tags) without return types