code: def init_prompt_toolkit_cli(self):
      if self.simple_prompt:
          # Fall back to plain non-interactive output for tests.
          # This is very limited, and only accepts a single line.
          def prompt():
              isp = self.input_splitter
              prompt_text = "".join(
                  x[1] for x in self.prompts.in_prompt_tokens()
              )
              prompt_continuation = "".join(
                  x[1]
                  for x in self.prompts.continuation_prompt_tokens()
              )
              while isp.push_accepts_more():
                  line = cast_unicode_py2(input(prompt_text))
                  isp.push(line)
                  prompt_text = prompt_continuation
              return isp.source_reset()
  
          self.prompt_for_code = prompt
          return
  
      # Set up keyboard shortcuts
      kbmanager = KeyBindingManager.for_prompt(
          enable_open_in_editor=self.extra_open_editor_shortcuts,
      )
      register_ipython_shortcuts(kbmanager.registry, self)
  
      # Pre-populate history from IPython's history database
      history = InMemoryHistory()
      last_cell = ""
      for __, ___, cell in self.history_manager.get_tail(
          self.history_load_length, include_latest=True
      ):
          # Ignore blank lines and consecutive duplicates
          cell = cell.rstrip()
          if cell and (cell != last_cell):
              history.append(cell)
              last_cell = cell
  
      self._style = self._make_style_from_name_or_cls(
          self.highlighting_style
      )
      self.style = DynamicStyle(lambda: self._style)
  
      editing_mode = getattr(EditingMode, self.editing_mode.upper())
  
      def patch_stdout(**kwargs):
          return self.pt_cli.patch_stdout_context(**kwargs)
  
      self._pt_app = create_prompt_application(
          editing_mode=editing_mode,
          key_bindings_registry=kbmanager.registry,
          history=history,
          completer=IPythonPTCompleter(
              shell=self, patch_stdout=patch_stdout
          ),
          enable_history_search=True,
          style=self.style,
          mouse_support=self.mouse_support,
          **self._layout_options(),
      )
      self._eventloop = create_eventloop(self.inputhook)
      self.pt_cli = CommandLineInterface(
          self._pt_app,
          eventloop=self._eventloop,
          output=create_output(true_color=self.true_color),
      )
  
imports: from __future__ import print_function
  import os
  import sys
  import warnings
  from warnings import warn
  from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
  from IPython.utils import io
  from IPython.utils.py3compat import PY3, cast_unicode_py2, input, string_types
  from IPython.utils.terminal import toggle_set_term_title, set_term_title
  from IPython.utils.process import abbrev_cwd
  from traitlets import Bool, Unicode, Dict, Integer, observe, Instance, Type, default, Enum, Union
  from prompt_toolkit.document import Document
  from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
  from prompt_toolkit.filters import HasFocus, Condition, IsDone
  from prompt_toolkit.history import InMemoryHistory
  from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout, create_output
  from prompt_toolkit.interface import CommandLineInterface
  from prompt_toolkit.key_binding.manager import KeyBindingManager
  from prompt_toolkit.layout.processors import ConditionalProcessor, HighlightMatchingBracketProcessor
  from prompt_toolkit.styles import PygmentsStyle, DynamicStyle
  from pygments.styles import get_style_by_name
  from pygments.style import Style
  from pygments.token import Token
  from .debugger import TerminalPdb, Pdb
  from .magics import TerminalMagics
  from .pt_inputhooks import get_inputhook_name_and_func
  from .prompts import Prompts, ClassicPrompts, RichPromptDisplayHook
  from .ptutils import IPythonPTCompleter, IPythonPTLexer
  from .shortcuts import register_ipython_shortcuts
  from pygments.style import Style
label_desc: Use image node_id 10 for calling the TerminalInteractiveShell obj's underlying member method code with example usage: obj.init_prompt_toolkit_cli() and returns: self, isp