code: def plot_to_image(figure):
      """Converts a matplotlib figure into a TF image e.g. for TensorBoard."""
      figure.canvas.draw()
      width, height = figure.canvas.get_width_height()
      data_np = np.frombuffer(
          figure.canvas.tostring_rgb(), dtype="uint8"
      )
      data_np = data_np.reshape([width, height, 3])
      image = tf.expand_dims(data_np, 0)
      return image
  
imports: import os
  import pickle
  import re
  import matplotlib.pyplot
  import numpy
  import tensorflow
  from tensorflow_graphics.projects.points_to_3Dobjects.utils import tf_utils
  from google3.pyglib import gfile
label_desc: Use image node_id 1 for calling a global function with example usage: plot_to_image(figure) and returns: image