code: def purge_xrefs(app, env, docname):
      if not hasattr(env, "all_sampledata_xrefs"):
          return
  
      env.all_sampledata_xrefs = [
          xref
          for xref in env.all_sampledata_xrefs
          if xref["docname"] != docname
      ]
  
imports: from __future__ import annotations
  from sphinx.util import logging
  from os.path import basename
  from docutils import nodes
  from sphinx.locale import _
  from .None import PARALLEL_SAFE
  from .bokeh_directive import BokehDirective
  from .util import get_sphinx_resources
label_desc: Use image node_id 2 for calling a global function with example usage: purge_xrefs(app, env, docname) without return types