code: def latex2png(latex, filename, fontset="cm"):
      latex = "$%s$" % latex
      orig_fontset = rcParams["mathtext.fontset"]
      rcParams["mathtext.fontset"] = fontset
      if os.path.exists(filename):
          depth = mathtext_parser.get_depth(latex, dpi=100)
      else:
          try:
              depth = mathtext_parser.to_png(filename, latex, dpi=100)
          except:
              warnings.warn(
                  "Could not render math expression %s" % latex, Warning
              )
              depth = 0
      rcParams["mathtext.fontset"] = orig_fontset
      sys.stdout.write("#")
      sys.stdout.flush()
      return depth
  
file_path: catboost/contrib/python/matplotlib/py2/matplotlib/sphinxext/mathmpl.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  import hashlib
  import os
  import sys
  import warnings
  from docutils import nodes
  from docutils.parsers.rst import directives
  import sphinx
  from matplotlib import rcParams
  from matplotlib.mathtext import MathTextParser
label_desc: Use image node_id 4 for calling a global function with example usage: latex2png(latex, filename, fontset) and returns: depth