code: def mark_wf_labels(app, document):
      """
      To make graphs referenceable, we need to move the reference from
      the "htmlonly" (or "latexonly") node to the actual figure node
      itself.
      """
      for name, explicit in list(document.nametypes.items()):
          if not explicit:
              continue
          labelid = document.nameids[name]
          if labelid is None:
              continue
          node = document.ids[labelid]
          if node.tagname in ("html_only", "latex_only"):
              for n in node:
                  if n.tagname == "figure":
                      sectname = name
                      for c in n:
                          if c.tagname == "caption":
                              sectname = c.astext()
                              break
  
                      node["ids"].remove(labelid)
                      node["names"].remove(name)
                      n["ids"].append(labelid)
                      n["names"].append(name)
                      document.settings.env.labels[name] = (
                          document.settings.env.docname,
                          labelid,
                          sectname,
                      )
                      break
  
imports: import sys
  import os
  import shutil
  import io
  import re
  import textwrap
  from os.path import relpath
  from errno import EEXIST
  import traceback
label_desc: Use image node_id 6 for calling a global function with example usage: mark_wf_labels(app, document) without return types