code: def parse_config(app):
      """Process the Sphinx Gallery configuration"""
      try:
          plot_gallery = eval(app.builder.config.plot_gallery)
      except TypeError:
          plot_gallery = bool(app.builder.config.plot_gallery)
  
      gallery_conf = copy.deepcopy(DEFAULT_GALLERY_CONF)
      gallery_conf.update(app.config.sphinx_gallery_conf)
      gallery_conf.update(plot_gallery=plot_gallery)
      gallery_conf.update(
          abort_on_example_error=app.builder.config.abort_on_example_error
      )
      gallery_conf["src_dir"] = app.builder.srcdir
  
      backreferences_warning = """\n========
  Sphinx-Gallery now requires you to set the configuration variable
  'backreferences_dir' in your config to activate the
  backreferences. That is mini galleries clustered by the functions used
  in the example scripts. Have a look at it in sphinx-gallery
  
  https://sphinx-gallery.readthedocs.io/en/stable/index.html#examples-using-numpy-linspace
  """
  
      if gallery_conf.get("mod_example_dir", False):
          update_msg = """\nFor a quick fix try replacing 'mod_example_dir'
  by 'backreferences_dir' in your conf.py file. If that does not solve the
  present issue read carefully how to update in the online documentation
  
  https://sphinx-gallery.readthedocs.io/en/latest/advanced_configuration.html#references-to-examples"""
  
          gallery_conf["backreferences_dir"] = gallery_conf[
              "mod_example_dir"
          ]
          logger.warning(
              "Old configuration for backreferences detected \n"
              "using the configuration variable `mod_example_dir`\n"
              "%s%s",
              backreferences_warning,
              update_msg,
              type=DeprecationWarning,
          )
  
      elif gallery_conf["backreferences_dir"] is None:
          no_care_msg = """
  If you don't care about this features set in your conf.py
  'backreferences_dir': False\n"""
  
          logger.warning(backreferences_warning + no_care_msg)
  
          gallery_conf["backreferences_dir"] = os.path.join(
              "modules", "generated"
          )
          logger.warning(
              "Using old default 'backreferences_dir':'%s'.\n"
              "This will be disabled in future releases\n",
              gallery_conf["backreferences_dir"],
              type=DeprecationWarning,
          )
  
      # this assures I can call the config in other places
      app.config.sphinx_gallery_conf = gallery_conf
      app.config.html_static_path.append(glr_path_static())
  
      return gallery_conf
  
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 2 for calling a global function with example usage: parse_config(app) and returns: gallery_conf