code: def latex_to_png_mpl(s, wrap):
      try:
          from matplotlib import mathtext
          from pyparsing import ParseFatalException
      except ImportError:
          return None
  
      # mpl mathtext doesn't support display math, force inline
      s = s.replace("$$", "$")
      if wrap:
          s = "${0}$".format(s)
  
      try:
          mt = mathtext.MathTextParser("bitmap")
          f = BytesIO()
          mt.to_png(f, s, fontsize=12)
          return f.getvalue()
      except (ValueError, RuntimeError, ParseFatalException):
          return None
  
file_path: catboost/contrib/python/ipython/py2/IPython/lib/latextools.py
imports: from io import BytesIO, open
  import os
  import tempfile
  import shutil
  import subprocess
  from IPython.utils.process import find_cmd, FindCmdError
  from traitlets.config import get_config
  from traitlets.config.configurable import SingletonConfigurable
  from traitlets import List, Bool, Unicode
  from IPython.utils.py3compat import cast_unicode, cast_unicode_py2, PY3
label_desc: Use image node_id 2 for calling a global function with example usage: latex_to_png_mpl(s, wrap) and returns: f, None, None