code: def embed(**kwargs):
      """Call this to embed IPython at the current point in your program.
  
      The first invocation of this will create an :class:`InteractiveShellEmbed`
      instance and then call it.  Consecutive calls just call the already
      created instance.
  
      If you don't want the kernel to initialize the namespace
      from the scope of the surrounding function,
      and/or you want to load full IPython configuration,
      you probably want `IPython.start_ipython()` instead.
  
      Here is a simple example::
  
          from IPython import embed
          a = 10
          b = 20
          embed(header='First time')
          c = 30
          d = 40
          embed()
  
      Full customization can be done by passing a :class:`Config` in as the
      config argument.
      """
      config = kwargs.get("config")
      header = kwargs.pop("header", "")
      compile_flags = kwargs.pop("compile_flags", None)
      if config is None:
          config = load_default_config()
          config.InteractiveShellEmbed = config.TerminalInteractiveShell
          kwargs["config"] = config
      # save ps1/ps2 if defined
      ps1 = None
      ps2 = None
      try:
          ps1 = sys.ps1
          ps2 = sys.ps2
      except AttributeError:
          pass
      # save previous instance
      saved_shell_instance = InteractiveShell._instance
      if saved_shell_instance is not None:
          cls = type(saved_shell_instance)
          cls.clear_instance()
      frame = sys._getframe(1)
      shell = InteractiveShellEmbed.instance(
          _init_location_id="%s:%s"
          % (frame.f_code.co_filename, frame.f_lineno),
          **kwargs,
      )
      shell(
          header=header,
          stack_depth=2,
          compile_flags=compile_flags,
          _call_location_id="%s:%s"
          % (frame.f_code.co_filename, frame.f_lineno),
      )
      InteractiveShellEmbed.clear_instance()
      # restore previous instance
      if saved_shell_instance is not None:
          cls = type(saved_shell_instance)
          cls.clear_instance()
          for subclass in cls._walk_mro():
              subclass._instance = saved_shell_instance
      if ps1 is not None:
          sys.ps1 = ps1
          sys.ps2 = ps2
  
imports: from __future__ import with_statement
  from __future__ import print_function
  import sys
  import warnings
  from IPython.core import ultratb, compilerop
  from IPython.core import magic_arguments
  from IPython.core.magic import Magics, magics_class, line_magic
  from IPython.core.interactiveshell import DummyMod, InteractiveShell
  from IPython.terminal.interactiveshell import TerminalInteractiveShell
  from IPython.terminal.ipapp import load_default_config
  from traitlets import Bool, CBool, Unicode
  from IPython.utils.io import ask_yes_no
label_desc: Use image node_id 1 for calling a global function with example usage: embed() without return types