code: def subset_elements(
      el: etree.Element, retained_ids: Set[str]
  ) -> bool:
      # Keep elements if their id is in the subset, or any of their children's id is.
      # Drop elements whose id is not in the subset, and either have no children,
      # or all their children are being dropped.
      if el.attrib.get("id") in retained_ids:
          # if id is in the set, don't recurse; keep whole subtree
          return True
      # recursively subset all the children; we use a list comprehension instead
      # of a parentheses-less generator expression because we don't want any() to
      # short-circuit, as our function has a side effect of dropping empty elements.
      if any([subset_elements(e, retained_ids) for e in el]):
          return True
      assert len(el) == 0
      parent = el.getparent()
      if parent is not None:
          parent.remove(el)
      return False
  
file_path: catboost/contrib/python/fonttools/fontTools/subset/svg.py
imports: from __future__ import annotations
  import re
  from functools import lru_cache
  from itertools import chain, count
  from typing import Dict, Iterable, Iterator, List, Optional, Set, Tuple
  from fontTools import ttLib
  from fontTools.subset.util import _add_method
  from fontTools.ttLib.tables.S_V_G_ import SVGDocument
label_desc: Use image node_id 6 for calling a global function with example usage: subset_elements(el, retained_ids) and returns: False, True, True