code: def setup(app):
      setup.app = app
  
      app.add_directive("ipython", IPythonDirective)
      app.add_config_value("ipython_savefig_dir", "savefig", "env")
      app.add_config_value(
          "ipython_rgxin", re.compile("In \[(\d+)\]:\s?(.*)\s*"), "env"
      )
      app.add_config_value(
          "ipython_rgxout", re.compile("Out\[(\d+)\]:\s?(.*)\s*"), "env"
      )
      app.add_config_value("ipython_promptin", "In [%d]:", "env")
      app.add_config_value("ipython_promptout", "Out[%d]:", "env")
  
      # We could just let matplotlib pick whatever is specified as the default
      # backend in the matplotlibrc file, but this would cause issues if the
      # backend didn't work in headless environments. For this reason, 'agg'
      # is a good default backend choice.
      app.add_config_value("ipython_mplbackend", "agg", "env")
  
      # If the user sets this config value to `None`, then EmbeddedSphinxShell's
      # __init__ method will treat it as [].
      execlines = [
          "import numpy as np",
          "import matplotlib.pyplot as plt",
      ]
      app.add_config_value("ipython_execlines", execlines, "env")
  
      app.add_config_value("ipython_holdcount", True, "env")
  
      metadata = {
          "parallel_read_safe": True,
          "parallel_write_safe": True,
      }
      return metadata
  
imports: from __future__ import print_function
  import atexit
  import errno
  import os
  import re
  import sys
  import tempfile
  import ast
  import warnings
  import shutil
  from docutils.parsers.rst import directives
  from docutils.parsers.rst import Directive
  from traitlets.config import Config
  from IPython import InteractiveShell
  from IPython.core.profiledir import ProfileDir
  from IPython.utils import io
  from IPython.utils.py3compat import PY3
label_desc: Use image node_id 2 for calling a global function with example usage: setup(app) and returns: metadata