code: def embed(globals=None, locals=None, configure=None,
            vi_mode=False, history_filename=None, title=None,
            startup_paths=None, patch_stdout=False, return_asyncio_coroutine=False):
      
      assert configure is None or callable(configure)
  
      # Default globals/locals
      if globals is None:
          globals = {
              '__name__': '__main__',
              '__package__': None,
              '__doc__': None,
              '__builtins__': six.moves.builtins,
          }
  
      locals = locals or globals
  
      def get_globals():
          return globals
  
      def get_locals():
          return locals
  
      # Create eventloop.
      if return_asyncio_coroutine:
          use_asyncio_event_loop()
  
      # Create REPL.
      repl = PythonRepl(get_globals=get_globals, get_locals=get_locals, vi_mode=vi_mode,
                        history_filename=history_filename, startup_paths=startup_paths)
  
      if title:
          repl.terminal_title = title
  
      if configure:
          configure(repl)
  
      app = repl.app
  
      # Start repl.
      patch_context = patch_stdout_context() if patch_stdout else DummyContext()
  
      if return_asyncio_coroutine: # XXX
          def coroutine():
              with patch_context:
                  while True:
                      iterator = iter(app.run_async().to_asyncio_future())
                      try:
                          while True:
                              yield next(iterator)
                      except StopIteration as exc:
                          text = exc.args[0]
                      repl._process_text(text)
          return coroutine()
      else:
          with patch_context:
              repl.run()
docs: Call this to embed  Python shell at the current point in your program.
      It's similar to `IPython.embed` and `bpython.embed`. ::
  
          from prompt_toolkit.contrib.repl import embed
          embed(globals(), locals())
  
      :param vi_mode: Boolean. Use Vi instead of Emacs key bindings.
      :param configure: Callable that will be called with the `PythonRepl` as a first
                        argument, to trigger configuration.
      :param title: Title to be displayed in the terminal titlebar. (None or string.)