code: def main(app):
      target_dir = os.path.join(app.builder.srcdir, "paper_figures")
      source_dir = os.path.abspath(
          app.builder.srcdir + "/../" + "paper_figures"
      )
  
      try:
          plot_gallery = eval(app.builder.config.plot_gallery)
      except TypeError:
          plot_gallery = bool(app.builder.config.plot_gallery)
  
      if not os.path.exists(source_dir):
          os.makedirs(source_dir)
      if not os.path.exists(target_dir):
          os.makedirs(target_dir)
  
      EB = ExampleBuilder(
          source_dir,
          target_dir,
          execute_files=plot_gallery,
          contents_file="contents.txt",
          dir_info_file="README.rst",
          sphinx_tag_base="paper_fig",
          template_example=RST_TEMPLATE,
      )
      EB.run()
  
imports: import os
  from example_builder import ExampleBuilder
label_desc: Use image node_id 1 for calling a global function with example usage: main(app) without return types