code: def math_to_image(
      s,
      filename_or_obj,
      prop=None,
      dpi=None,
      format=None,
      *,
      color=None,
  ):
      """
      Given a math expression, renders it in a closely-clipped bounding
      box to an image file.
  
      Parameters
      ----------
      s : str
          A math expression.  The math portion must be enclosed in dollar signs.
      filename_or_obj : str or path-like or file-like
          Where to write the image data.
      prop : `.FontProperties`, optional
          The size and style of the text.
      dpi : float, optional
          The output dpi.  If not set, the dpi is determined as for
          `.Figure.savefig`.
      format : str, optional
          The output format, e.g., 'svg', 'pdf', 'ps' or 'png'.  If not set, the
          format is determined as for `.Figure.savefig`.
      color : str, optional
          Foreground color, defaults to :rc:`text.color`.
      """
      from matplotlib import figure
  
      parser = MathTextParser("path")
      width, height, depth, _, _ = parser.parse(s, dpi=72, prop=prop)
  
      fig = figure.Figure(figsize=(width / 72.0, height / 72.0))
      fig.text(0, depth / height, s, fontproperties=prop, color=color)
      fig.savefig(filename_or_obj, dpi=dpi, format=format)
  
      return depth
  
file_path: matplotlib/lib/matplotlib/mathtext.py
imports: import functools
  import logging
  import matplotlib
  from matplotlib import _api, _mathtext
  from matplotlib.ft2font import LOAD_NO_HINTING
  from matplotlib.font_manager import FontProperties
  from ._mathtext import RasterParse, VectorParse, get_unicode_index
label_desc: Use image node_id 1 for calling a global function with example usage: math_to_image(s, filename_or_obj, prop, dpi, format) and returns: depth