code: def save_missing_references_handler(app, exc):
      """
      At the end of the sphinx build, check that all lines of the existing JSON
      file are still necessary.
  
      If the configuration value ``missing_references_write_json`` is set
      then write a new JSON file containing missing references.
      """
      if not app.config.missing_references_enabled:
          # no-op when we are disabled.
          return
  
      _warn_unused_missing_references(app)
  
      json_path = (
          Path(app.confdir) / app.config.missing_references_filename
      )
  
      references_warnings = getattr(
          app.env, "missing_references_warnings", {}
      )
  
      if app.config.missing_references_write_json:
          _write_missing_references_json(references_warnings, json_path)
  
imports: from collections import defaultdict
  import json
  import logging
  from pathlib import Path
  from docutils.utils import get_source_line
  from docutils import nodes
  from sphinx.util import logging
  import matplotlib
label_desc: Use image node_id 6 for calling a global function with example usage: save_missing_references_handler(app, exc) without return types