code: def figure_rst(figure_list, sources_dir):
      """Given a list of paths to figures generate the corresponding rst
  
      Depending on whether we have one or more figures, we use a
      single rst call to 'image' or a horizontal list.
  
      Parameters
      ----------
      figure_list : list of str
          Strings are the figures' absolute paths
      sources_dir : str
          absolute path of Sphinx documentation sources
  
      Returns
      -------
      images_rst : str
          rst code to embed the images in the document
      fig_num : int
          number of figures saved
      """
  
      figure_paths = [
          os.path.relpath(figure_path, sources_dir)
          .replace(os.sep, "/")
          .lstrip("/")
          for figure_path in figure_list
      ]
      images_rst = ""
      if len(figure_paths) == 1:
          figure_name = figure_paths[0]
          images_rst = SINGLE_IMAGE % figure_name
      elif len(figure_paths) > 1:
          images_rst = HLIST_HEADER
          for figure_name in figure_paths:
              images_rst += HLIST_IMAGE_TEMPLATE % figure_name
  
      return images_rst, len(figure_list)
  
imports: from __future__ import division, print_function, absolute_import
  from time import time
  import ast
  import codecs
  import hashlib
  import os
  import re
  import shutil
  import subprocess
  import sys
  import traceback
  from distutils.version import LooseVersion
  from io import StringIO
  import matplotlib
  import matplotlib.pyplot
  import sphinx
  from .None import glr_path_static
  from .None import sphinx_compatibility
  from .backreferences import write_backreferences, _thumbnail_div
  from .downloads import CODE_DOWNLOAD
  from .py_source_parser import split_code_and_text_blocks
  from .notebook import jupyter_notebook, save_notebook
label_desc: Use image node_id 6 for calling a global function with example usage: figure_rst(figure_list, sources_dir) and returns: images_rst,  len