code: def setup(app):
      """Setup sphinx-gallery sphinx extension"""
      sphinx_compatibility._app = app
  
      app.add_config_value(
          "sphinx_gallery_conf", DEFAULT_GALLERY_CONF, "html"
      )
      for key in ["plot_gallery", "abort_on_example_error"]:
          app.add_config_value(
              key, get_default_config_value(key), "html"
          )
  
      app.add_stylesheet("gallery.css")
  
      # Sphinx < 1.6 calls it `_extensions`, >= 1.6 is `extensions`.
      extensions_attr = (
          "_extensions" if hasattr(app, "_extensions") else "extensions"
      )
      if "sphinx.ext.autodoc" in getattr(app, extensions_attr):
          app.connect(
              "autodoc-process-docstring", touch_empty_backreferences
          )
  
      app.connect("builder-inited", generate_gallery_rst)
  
      app.connect("build-finished", sumarize_failing_examples)
      app.connect("build-finished", embed_code_links)
      metadata = {"parallel_read_safe": True}
      return metadata
  
file_path: tensorly/doc/sphinx_ext/sphinx_gallery/gen_gallery.py
imports: from __future__ import division, print_function, absolute_import
  import codecs
  import copy
  import re
  import os
  from .None import glr_path_static
  from .None import sphinx_compatibility
  from .gen_rst import generate_dir_rst, SPHX_GLR_SIG
  from .docs_resolv import embed_code_links
  from .downloads import generate_zipfiles
label_desc: Use image node_id 9 for calling a global function with example usage: setup(app) and returns: metadata