def embed(**kwargs):
    """
    Copied from `IPython/terminal/embed.py`, but using our `InteractiveShellEmbed` instead.
    """
    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
    shell = InteractiveShellEmbed.instance(**kwargs)
    initialize_extensions(shell, config["InteractiveShellApp"]["extensions"])
    run_exec_lines(shell, config["InteractiveShellApp"]["exec_lines"])
    run_startup_scripts(shell)
    shell(header=header, stack_depth=2, compile_flags=compile_flags)

    Copied from `IPython/terminal/embed.py`, but using our `InteractiveShellEmbed` instead.
    
src/ptpython/ipython.py