code: def _feed_cli_with_input(
      text,
      editing_mode=EditingMode.EMACS,
      clipboard=None,
      history=None,
      multiline=False,
      check_line_ending=True,
      pre_run_callback=None,
  ):
      """
      Create a CommandLineInterface, feed it with the given user input and return
      the CLI object.
  
      This returns a (result, CLI) tuple.
      """
      # If the given text doesn't end with a newline, the interface won't finish.
      if check_line_ending:
          assert text.endswith("\n")
  
      loop = PosixEventLoop()
      try:
          inp = PipeInput()
          inp.send_text(text)
          cli = CommandLineInterface(
              application=Application(
                  buffer=Buffer(
                      accept_action=AcceptAction.RETURN_DOCUMENT,
                      history=history,
                      is_multiline=multiline,
                  ),
                  editing_mode=editing_mode,
                  clipboard=clipboard or InMemoryClipboard(),
                  key_bindings_registry=KeyBindingManager.for_prompt().registry,
              ),
              eventloop=loop,
              input=inp,
              output=DummyOutput(),
          )
  
          if pre_run_callback:
              pre_run_callback(cli)
  
          result = cli.run()
          return result, cli
      finally:
          loop.close()
          inp.close()
  
imports: from __future__ import unicode_literals
  from prompt_toolkit.application import Application
  from prompt_toolkit.buffer import Buffer, AcceptAction
  from prompt_toolkit.clipboard import InMemoryClipboard, ClipboardData
  from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
  from prompt_toolkit.eventloop.posix import PosixEventLoop
  from prompt_toolkit.history import InMemoryHistory
  from prompt_toolkit.input import PipeInput
  from prompt_toolkit.interface import CommandLineInterface
  from prompt_toolkit.key_binding.manager import KeyBindingManager
  from prompt_toolkit.output import DummyOutput
  from prompt_toolkit.terminal.vt100_input import ANSI_SEQUENCES
  from functools import partial
  import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: _feed_cli_with_input(text, editing_mode, clipboard, history, multiline, check_line_ending, pre_run_callback) and returns: result,  cli