code: def ipexec(fname, options=None, commands=()):
      """Utility to call 'ipython filename'.
  
      Starts IPython with a minimal and safe configuration to make startup as fast
      as possible.
  
      Note that this starts IPython in a subprocess!
  
      Parameters
      ----------
      fname : str
        Name of file to be executed (should have .py or .ipy extension).
  
      options : optional, list
        Extra command-line flags to be passed to IPython.
  
      commands : optional, list
        Commands to send in on stdin
  
      Returns
      -------
      (stdout, stderr) of ipython subprocess.
      """
      if options is None:
          options = []
  
      cmdargs = default_argv() + options
  
      test_dir = os.path.dirname(__file__)
  
      ipython_cmd = get_ipython_cmd()
      # Absolute path for filename
      full_fname = os.path.join(test_dir, fname)
      full_cmd = ipython_cmd + cmdargs + [full_fname]
      env = os.environ.copy()
      # FIXME: ignore all warnings in ipexec while we have shims
      # should we keep suppressing warnings here, even after removing shims?
      env["PYTHONWARNINGS"] = "ignore"
      # env.pop('PYTHONWARNINGS', None)  # Avoid extraneous warnings appearing on stderr
      for k, v in env.items():
          # Debug a bizarre failure we've seen on Windows:
          # TypeError: environment can only contain strings
          if not isinstance(v, str):
              print(k, v)
      p = Popen(full_cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE, env=env)
      out, err = p.communicate(
          input=py3compat.str_to_bytes("\n".join(commands)) or None
      )
      out, err = py3compat.bytes_to_str(out), py3compat.bytes_to_str(
          err
      )
      # `import readline` causes 'ESC[?1034h' to be output sometimes,
      # so strip that out before doing comparisons
      if out:
          out = re.sub(r"\x1b\[[^h]+h", "", out)
      return out, err
  
imports: from __future__ import absolute_import
  import os
  import re
  import sys
  import tempfile
  from contextlib import contextmanager
  from io import StringIO
  from subprocess import Popen, PIPE
  from traitlets.config.loader import Config
  from IPython.utils.process import get_output_error_code
  from IPython.utils.text import list_strings
  from IPython.utils.io import temp_pyfile, Tee
  from IPython.utils import py3compat
  from IPython.utils.encoding import DEFAULT_ENCODING
  from .None import decorators
  from .None import skipdoctest
label_desc: Use image node_id 6 for calling a global function with example usage: ipexec(fname, options, commands) and returns: out,  err