Starts interactive session. Similar to keyboard command in matlab.
    Wrapper around IPython.embed

    Notes:
        #https://github.com/ipython/ipython/wiki/Cookbook%3a-Updating-code-for-use-with-IPython-0.11-and-later

        import IPython
        x = 3
        IPython.embed()
        c = IPython.Config()
        c.InteractiveShellApp.exec_lines = [
            '%pylab qt4',
            "print 'System Ready!'",
        ]

        def foo():
            return x + 3

        a = 3
        def bar():
            return a + 3
        bar()
        #NameError: global name 'a' is not defined


        from IPython.terminal.ipapp import TerminalIPythonApp
        x = 3
        app = TerminalIPythonApp.instance()
        app.initialize(argv=[]) # argv=[] instructs IPython to ignore sys.argv
        app.start()


    Args:
        parent_locals (None):
        parent_globals (None):
        exec_lines (None):
        remove_pyqt_hook (bool):
        N (int):

    CommandLine:
        python -m utool.util_dbg --test-embed

    References:
       http://stackoverflow.com/questions/27911570/can-you-specify-a-command-to-run-after-you-embed-into-ipython/27914204#27914204
       http://stackoverflow.com/questions/15167200/how-do-i-embed-an-ipython-interpreter-into-an-application-running-in-an-ipython

    Notes:
        Use cases I want to achieve

        1) Simply stop execution and embed in an IPython terminal session
        2) Like case 1, but execute a specific set of command (eg '%gui qt')
           AFTER IPython has started
        3) Embed and pause GUI execution (this is just case 1)
        3) Embed and let GUI execution continue while embeded. (basically just need case 2)

    TODO:
        try:
            get_ipython
        except NameError:
            banner=exit_msg=''
        else:
            banner = '*** Nested interpreter ***'
            exit_msg = '*** Back in main IPython ***'

        # First import the embed function
        from IPython.frontend.terminal.embed import InteractiveShellEmbed
        # Now create the IPython shell instance. Put ipshell() anywhere in your code
        # where you want it to open.
        ipshell = InteractiveShellEmbed(banner1=banner, exit_msg=exit_msg)
        #Then use ipshell() whenever you want to be dropped into an IPython shell. This
        #will allow you to embed (and even nest) IPython interpreters in your code and
        #inspect objects or the state of the program.

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_dbg import *  # NOQA
        >>> # build test data
        >>> parent_locals = None
        >>> parent_globals = None
        >>> exec_lines = None
        >>> remove_pyqt_hook = True
        >>> N = 0
        >>> # execute function
        >>> result = embed(parent_locals, parent_globals, exec_lines, remove_pyqt_hook, N)
        >>> # verify results
        >>> print(result)

def _wip_embed(parent_locals=None, parent_globals=None, exec_lines=None,
               remove_pyqt_hook=True, N=0):
    """
    Starts interactive session. Similar to keyboard command in matlab.
    Wrapper around IPython.embed

    Notes:
        #https://github.com/ipython/ipython/wiki/Cookbook%3a-Updating-code-for-use-with-IPython-0.11-and-later

        import IPython
        x = 3
        IPython.embed()
        c = IPython.Config()
        c.InteractiveShellApp.exec_lines = [
            '%pylab qt4',
            "print 'System Ready!'",
        ]

        def foo():
            return x + 3

        a = 3
        def bar():
            return a + 3
        bar()
        #NameError: global name 'a' is not defined


        from IPython.terminal.ipapp import TerminalIPythonApp
        x = 3
        app = TerminalIPythonApp.instance()
        app.initialize(argv=[]) # argv=[] instructs IPython to ignore sys.argv
        app.start()


    Args:
        parent_locals (None):
        parent_globals (None):
        exec_lines (None):
        remove_pyqt_hook (bool):
        N (int):

    CommandLine:
        python -m utool.util_dbg --test-embed

    References:
       http://stackoverflow.com/questions/27911570/can-you-specify-a-command-to-run-after-you-embed-into-ipython/27914204#27914204
       http://stackoverflow.com/questions/15167200/how-do-i-embed-an-ipython-interpreter-into-an-application-running-in-an-ipython

    Notes:
        Use cases I want to achieve

        1) Simply stop execution and embed in an IPython terminal session
        2) Like case 1, but execute a specific set of command (eg '%gui qt')
           AFTER IPython has started
        3) Embed and pause GUI execution (this is just case 1)
        3) Embed and let GUI execution continue while embeded. (basically just need case 2)

    TODO:
        try:
            get_ipython
        except NameError:
            banner=exit_msg=''
        else:
            banner = '*** Nested interpreter ***'
            exit_msg = '*** Back in main IPython ***'

        # First import the embed function
        from IPython.frontend.terminal.embed import InteractiveShellEmbed
        # Now create the IPython shell instance. Put ipshell() anywhere in your code
        # where you want it to open.
        ipshell = InteractiveShellEmbed(banner1=banner, exit_msg=exit_msg)
        #Then use ipshell() whenever you want to be dropped into an IPython shell. This
        #will allow you to embed (and even nest) IPython interpreters in your code and
        #inspect objects or the state of the program.

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_dbg import *  # NOQA
        >>> # build test data
        >>> parent_locals = None
        >>> parent_globals = None
        >>> exec_lines = None
        >>> remove_pyqt_hook = True
        >>> N = 0
        >>> # execute function
        >>> result = embed(parent_locals, parent_globals, exec_lines, remove_pyqt_hook, N)
        >>> # verify results
        >>> print(result)
    """
    import utool as ut
    from functools import partial
    import IPython

    if parent_globals is None:
        parent_globals = get_parent_frame(N=N).f_globals
    if parent_locals is None:
        parent_locals = get_parent_frame(N=N).f_locals

    stackdepth = N  # NOQA
    getframe = partial(ut.get_parent_frame, N=N)  # NOQA

    exec(execstr_dict(parent_globals, 'parent_globals'))
    exec(execstr_dict(parent_locals,  'parent_locals'))
    print('')
    print('================')
    print(ut.bubbletext('EMBEDDING'))
    print('================')
    print('[util] embedding')
    try:
        if remove_pyqt_hook:
            try:
                import guitool
                guitool.remove_pyqt_input_hook()
            except (ImportError, ValueError, AttributeError) as ex:
                #print(ex)
                printex(ex, iswarning=True)
                pass
            # make qt not loop forever (I had qflag loop forever with this off)
    except ImportError as ex:
        print(ex)
    user_ns = globals()
    user_ns = globals().copy()
    user_ns.update(locals())
    if parent_globals is not None:
        user_ns.update(parent_globals)
    if parent_locals is not None:
        user_ns.update(parent_locals)
    orig_argv = sys.argv  # NOQA
    print('About to start_ipython')
    config = IPython.Config()
    exec_lines_ = [
        '%pylab qt4',
        'print("Entered IPYTHON via utool")',
        'print("Entry Point: %r" % (ut.get_parent_frame(N=11).f_code.co_name,))',
        #'print("Entry Point: %r" % (ut.get_parent_frame(N=10).f_code.co_name,))',
        #'print("Entry Point: %r" % (ut.get_parent_frame(N=9).f_code.co_name,))',
        #'print("Entry Point: %r" % (ut.get_parent_frame(N=8).f_code.co_name,))',
        #'print("Entry Point: %r" % (ut.get_parent_frame(N=7).f_code.co_name,))',
        #'print("Entry Point: %r" % (ut.get_parent_frame(N=6).f_code.co_name,))',
        #'print("Entry Point: %r" % (ut.get_parent_frame(N=5).f_code.co_name,))',
        #execstr_dict(parent_locals)
    ] + ut.ensure_str_list(exec_lines if exec_lines is not None else [])
    config.InteractiveShellApp.exec_lines = exec_lines_
    print('Exec Lines: ')
    print(ut.indentjoin(exec_lines_, '\n    >>> '))
    IPython.start_ipython(config=config, argv=[], user_ns=user_ns)
    # Exit python immediately if specifed
    if user_ns.get('qqq', False) or vars.get('qqq', False) or user_ns.get('EXIT_NOW', False):
        print('[utool.embed] EXIT_NOW or qqq specified')
        sys.exit(1)