code: def visit_figmpl_html(self, node):
      imagedir, srcset, rel = _copy_images_figmpl(self, node)
  
      # /doc/examples/subd/plot_1.rst
      docsource = PurePath(self.document["source"])
      # /doc/
      # make sure to add the trailing slash:
      srctop = PurePath(self.builder.srcdir, "")
      # examples/subd/plot_1.rst
      relsource = relpath(docsource, srctop)
      # /doc/build/html
      desttop = PurePath(self.builder.outdir, "")
      # /doc/build/html/examples/subd
      dest = desttop / relsource
  
      # ../../_images/ for dirhtml and ../_images/ for html
      imagerel = PurePath(relpath(imagedir, dest.parent)).as_posix()
      if self.builder.name == "dirhtml":
          imagerel = f"..{imagerel}"
  
      # make uri also be relative...
      nm = PurePath(node["uri"][1:]).name
      uri = f"{imagerel}/{rel}{nm}"
  
      # make srcset str.  Need to change all the prefixes!
      maxsrc = uri
      srcsetst = ""
      if srcset:
          maxmult = -1
          for mult, src in srcset.items():
              nm = PurePath(src[1:]).name
              # ../../_images/plot_1_2_0x.png
              path = f"{imagerel}/{rel}{nm}"
              srcsetst += path
              if mult == 0:
                  srcsetst += ", "
              else:
                  srcsetst += f" {mult:1.2f}x, "
  
              if mult > maxmult:
                  maxmult = mult
                  maxsrc = path
  
          # trim trailing comma and space...
          srcsetst = srcsetst[:-2]
  
      alt = node["alt"]
      if node["class"] is not None:
          classst = " ".join(node["class"])
          classst = f'class="{classst}"'
  
      else:
          classst = ""
  
      stylers = ["width", "height", "scale"]
      stylest = ""
      for style in stylers:
          if node[style]:
              stylest += f"{style}: {node[style]};"
  
      figalign = node["align"] if node["align"] else "center"
  
      # <figure class="align-default" id="id1">
      # <a class="reference internal image-reference" href="_images/index-1.2x.png">
      # <img alt="_images/index-1.2x.png" src="_images/index-1.2x.png" style="width: 53%;" />
      # </a>
      # <figcaption>
      # <p><span class="caption-text">Figure caption is here....</span>
      # <a class="headerlink" href="#id1" title="Permalink to this image">#</a></p>
      # </figcaption>
      # </figure>
      img_block = (
          f'<img src="{uri}" style="{stylest}" srcset="{srcsetst}" '
          f'alt="{alt}" {classst}/>'
      )
      html_block = f'<figure class="align-{figalign}">\n'
      html_block += f'  <a class="reference internal image-reference" href="{maxsrc}">\n'
      html_block += f"    {img_block}\n  </a>\n"
      if node["caption"]:
          html_block += "  <figcaption>\n"
          html_block += f'   <p><span class="caption-text">{node["caption"]}</span></p>\n'
          html_block += "  </figcaption>\n"
      html_block += "</figure>\n"
      self.body.append(html_block)
  
imports: from docutils import nodes
  from docutils.parsers.rst import directives
  from docutils.parsers.rst.directives.images import Figure, Image
  import os
  from os.path import relpath
  from pathlib import PurePath, Path
  import shutil
  from sphinx.errors import ExtensionError
  import matplotlib
label_desc: Use image node_id 3 for calling a global function with example usage: visit_figmpl_html(node) without return types