class_docstr: Original class: `from plotly.io._base_renderers import SphinxGalleryRenderer`
  Modified to add `render_png` parameter.
class_docstr_tok: ["Original","class",":","`","from","plotly.io._base_renderers","import","SphinxGalleryRenderer","`","Modified","to","add","`","render_png","`","parameter","."]
docstr: Called by plotly.io.show
docstr_tok: ["Called","by","plotly.io.show"]
code: def render(self, fig_dict):
      """Called by plotly.io.show"""
      stack = inspect.stack()
      # Name of .py example script from which plot function was called
      try:
          filename = stack[3].filename  # let's hope this is robust...
      except (IndexError, AttributeError):  # python 2
          filename = stack[3][1]
      # NB: this works for multiple plots in the same file
      # It appears they are executed sequentially
      filename_root, _ = os.path.splitext(filename)
      filename_html = filename_root + ".html"
      filename_png = filename_root + ".png"
      _ = write_html(fig_dict, file=filename_html)
  
      # Whether to render the html image as a png for the thumbnail
      render_png = False
      if render_png:
          # Requires plotly-orca and xfvb
          # https://github.com/plotly/orca
          plotly.io.orca.config.use_xvfb = True
          figure = return_figure_from_figure_or_data(fig_dict, True)
          write_image(figure, filename_png)
      else:
          # The thumbnail isn't important, so we use a default image
          # Assumes the default image is one level above the .py file
          try:
              filename_default_image = (
                  Path(filename_root)
                  .parents[1]
                  .joinpath("default_thumb.png")
              )
              if not os.path.exists(filename_default_image):
                  # the .py file is in a subfolder (sub-gallery)
                  filename_default_image = (
                      Path(filename_root)
                      .parents[2]
                      .joinpath("default_thumb.png")
                  )
              shutil.copyfile(filename_default_image, filename_png)
          except FileNotFoundError:
              warnings.warn(
                  f"Thumbnail not found! Expected default_thumb.png to be "
                  f"in the parent folder of filename ({filename})."
              )
  
file_path: greykite/greykite/common/sphinx_plotly.py
imports: import inspect
  import os
  import shutil
  import warnings
  from glob import glob
  from pathlib import Path
  import plotly
  from plotly.io import write_html
  from plotly.io import write_image
  from plotly.io._base_renderers import ExternalRenderer
  from plotly.tools import return_figure_from_figure_or_data
label_desc: Use image node_id 1 for calling the SphinxGalleryRenderer obj's underlying member method code with example usage: obj.render(fig_dict) without return types