code: def write_backreferences(
      seen_backrefs, gallery_conf, target_dir, fname, snippet
  ):
      """Writes down back reference files, which include a thumbnail list
      of examples using a certain module"""
      if gallery_conf["backreferences_dir"] is None:
          return
  
      example_file = os.path.join(target_dir, fname)
      build_target_dir = os.path.relpath(
          target_dir, gallery_conf["src_dir"]
      )
      backrefs = scan_used_functions(example_file, gallery_conf)
      for backref in backrefs:
          include_path = os.path.join(
              gallery_conf["src_dir"],
              gallery_conf["backreferences_dir"],
              "%s.examples" % backref,
          )
          seen = backref in seen_backrefs
          with open(include_path, "a" if seen else "w") as ex_file:
              if not seen:
                  heading = "\n\nExamples using ``%s``" % backref
                  ex_file.write(heading + "\n")
                  ex_file.write("^" * len(heading) + "\n")
              ex_file.write(
                  _thumbnail_div(
                      build_target_dir, fname, snippet, is_backref=True
                  )
              )
              seen_backrefs.add(backref)
  
file_path: tensorly/doc/sphinx_ext/sphinx_gallery/backreferences.py
imports: from __future__ import print_function
  import ast
  import os
label_desc: Use image node_id 5 for calling a global function with example usage: write_backreferences(seen_backrefs, gallery_conf, target_dir, fname, snippet) without return types