code: def latex_to_png_dvipng(s, wrap):
      try:
          find_cmd("latex")
          find_cmd("dvipng")
      except FindCmdError:
          return None
      try:
          workdir = tempfile.mkdtemp()
          tmpfile = os.path.join(workdir, "tmp.tex")
          dvifile = os.path.join(workdir, "tmp.dvi")
          outfile = os.path.join(workdir, "tmp.png")
  
          with open(tmpfile, "w", encoding="utf8") as f:
              f.writelines(genelatex(s, wrap))
  
          with open(os.devnull, "wb") as devnull:
              subprocess.check_call(
                  [
                      "latex",
                      "-halt-on-error",
                      "-interaction",
                      "batchmode",
                      tmpfile,
                  ],
                  cwd=workdir,
                  stdout=devnull,
                  stderr=devnull,
              )
  
              subprocess.check_call(
                  [
                      "dvipng",
                      "-T",
                      "tight",
                      "-x",
                      "1500",
                      "-z",
                      "9",
                      "-bg",
                      "transparent",
                      "-o",
                      outfile,
                      dvifile,
                  ],
                  cwd=workdir,
                  stdout=devnull,
                  stderr=devnull,
              )
  
          with open(outfile, "rb") as f:
              return f.read()
      except subprocess.CalledProcessError:
          return None
      finally:
          shutil.rmtree(workdir)
  
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 3 for calling a global function with example usage: latex_to_png_dvipng(s, wrap) and returns: None, f, None