code: def clear_switches(doc: minidom.Document):
      switches = doc.getElementsByTagName("switch")
      for s in switches:
          children = s.childNodes
          assert len(children) == 2
          if (
              children[0].tagName == "g"
              and "requiredFeatures" in children[0].attributes
          ):
              s.parentNode.removeChild(s)
              s.unlink()
              continue
          assert children[0].tagName == "foreignObject"
          assert children[1].tagName == "text"
          c = children[1]
          s.removeChild(c)
          s.parentNode.insertBefore(c, s)
          s.parentNode.removeChild(s)
  
file_path: annotated_deep_learning_paper_implementations/utils/diagrams.py
imports: import shutil
  from pathlib import Path
  from typing import List
  from xml.dom import minidom
  from labml import monit
label_desc: Use image node_id 1 for calling a global function with example usage: clear_switches(doc) without return types