code: def figure_to_base64str(fig: matplotlib.figure.Figure) -> str:
      """Converts a Matplotlib figure to a base64 string encoding.
  
      Args:
        fig: A matplotlib Figure.
  
      Returns:
        A base64 encoding of the figure.
      """
      buf = io.BytesIO()
      fig.savefig(buf, bbox_inches="tight", format="png")
      return base64.b64encode(buf.getbuffer().tobytes()).decode("ascii")
  
file_path: model-card-toolkit/model_card_toolkit/utils/graphics.py
imports: import base64
  import io
  import logging
  from typing import Optional, Sequence, Tuple, Union
  import attr
  import matplotlib
  import matplotlib.pyplot
label_desc: Use image node_id 2 for calling a global function with example usage: figure_to_base64str(fig) and returns: base64