docstr: Render matplotlib figure into an image and add it to summary.
  
  Note that this requires the ``matplotlib`` package.
  
  Args:
      tag (string): Data identifier
      figure (matplotlib.pyplot.figure) or list of figures: figure or a list of figures
      global_step (int): Global step value to record
      close (bool): Flag to automatically close the figure
docstr_tok: ["Render","matplotlib","figure","into","an","image","and","add","it","to","summary",".","Note","that","this","requires","the","``","matplotlib","``","package",".","Args",":","tag","(","string",")",":","Data","identifier","figure","(","matplotlib.pyplot.figure",")","or","list","of","figures",":","figure","or","a","list","of","figures","global_step","(","int",")",":","Global","step","value","to","record","close","(","bool",")",":","Flag","to","automatically","close","the","figure"]
code: def add_figure(self, tag, figure, global_step=None, close=True):
      """Render matplotlib figure into an image and add it to summary.
  
      Note that this requires the ``matplotlib`` package.
  
      Args:
          tag (string): Data identifier
          figure (matplotlib.pyplot.figure) or list of figures: figure or a list of figures
          global_step (int): Global step value to record
          close (bool): Flag to automatically close the figure
      """
      self.add_image(tag, figure_to_image(figure, close), global_step)
  
imports: import gc
  import numpy
  import math
  import json
  import time
  from .summary import compute_curve
  from .utils import figure_to_image
  from .x2num import make_np
label_desc: Use image node_id 8 for calling the VisdomWriter obj's underlying member method code with example usage: obj.add_figure(tag, figure, global_step, close) without return types