code: def prepare_missing_references_handler(app):
      """
      Handler called to initialize this extension once the configuration
      is ready.
  
      Reads the missing references file and populates ``nitpick_ignore`` if
      appropriate.
      """
      if not app.config.missing_references_enabled:
          # no-op when we are disabled.
          return
  
      sphinx_logger = logging.getLogger("sphinx")
      missing_reference_filter = MissingReferenceFilter(app)
      for handler in sphinx_logger.handlers:
          if (
              isinstance(handler, sphinx_logging.WarningStreamHandler)
              and missing_reference_filter not in handler.filters
          ):
              # This *must* be the first filter, because subsequent filters
              # throw away the node information and then we can't identify
              # the reference uniquely.
              handler.filters.insert(0, missing_reference_filter)
  
      app.env.missing_references_ignored_references = {}
  
      json_path = (
          Path(app.confdir) / app.config.missing_references_filename
      )
      if not json_path.exists():
          return
  
      ignored_references = _read_missing_references_json(json_path)
  
      app.env.missing_references_ignored_references = ignored_references
  
      # If we are going to re-write the JSON file, then don't suppress missing
      # reference warnings. We want to record a full list of missing references
      # for use later. Otherwise, add all known missing references to
      # ``nitpick_ignore```
      if not app.config.missing_references_write_json:
          # Since Sphinx v6.2, nitpick_ignore may be a list, set or tuple, and
          # defaults to set.  Previously it was always a list.  Cast to list for
          # consistency across versions.
          app.config.nitpick_ignore = list(app.config.nitpick_ignore)
          app.config.nitpick_ignore.extend(ignored_references.keys())
  
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 9 for calling a global function with example usage: prepare_missing_references_handler(app) without return types