code: def render_figure_to_tensor(figure):
      import matplotlib
  
      matplotlib.use("Agg")
      import matplotlib.pyplot as plt
  
      figure.canvas.draw()
  
      # string = figure.canvas.tostring_argb()
  
      image = np.array(figure.canvas.renderer._renderer)
      plt.close(figure)
      del figure
  
      image = image_to_tensor(image)
      return image
  
file_path: pytorch-toolbelt/pytorch_toolbelt/utils/visualization.py
imports: from __future__ import absolute_import
  import itertools
  import math
  import warnings
  from typing import List, Iterable, Tuple, Optional
  import cv2
  import numpy
  from .torch_utils import image_to_tensor
label_desc: Use image node_id 3 for calling a global function with example usage: render_figure_to_tensor(figure) and returns: image