code: def setup(app):
      setup.app = app
      app.add_config_value("mathmpl_fontsize", 10.0, True)
      app.add_config_value("mathmpl_srcset", [], True)
      try:
          app.connect("config-inited", _config_inited)  # Sphinx 1.8+
      except ExtensionError:
          app.connect(
              "env-updated", lambda app, env: _config_inited(app, None)
          )
  
      # Add visit/depart methods to HTML-Translator:
      def visit_latex_math_html(self, node):
          source = self.document.attributes["source"]
          self.body.append(latex2html(node, source))
  
      def depart_latex_math_html(self, node):
          pass
  
      # Add visit/depart methods to LaTeX-Translator:
      def visit_latex_math_latex(self, node):
          inline = isinstance(node.parent, nodes.TextElement)
          if inline:
              self.body.append("$%s$" % node["latex"])
          else:
              self.body.extend(
                  [
                      "\\begin{equation}",
                      node["latex"],
                      "\\end{equation}",
                  ]
              )
  
      def depart_latex_math_latex(self, node):
          pass
  
      app.add_node(
          latex_math,
          html=(visit_latex_math_html, depart_latex_math_html),
          latex=(visit_latex_math_latex, depart_latex_math_latex),
      )
      app.add_role("mathmpl", math_role)
      app.add_directive("mathmpl", MathDirective)
      if sphinx.version_info < (1, 8):
          app.add_role("math", math_role)
          app.add_directive("math", MathDirective)
  
      metadata = {
          "parallel_read_safe": True,
          "parallel_write_safe": True,
      }
      return metadata
  
imports: import hashlib
  from pathlib import Path
  from docutils import nodes
  from docutils.parsers.rst import Directive, directives
  import sphinx
  from sphinx.errors import ConfigError, ExtensionError
  import matplotlib
  from matplotlib import _api, mathtext
  from matplotlib.rcsetup import validate_float_or_None
label_desc: Use image node_id 6 for calling a global function with example usage: setup(app) and returns: metadata