code: def _feed_cli_with_input(
      text,
      editing_mode=EditingMode.EMACS,
      clipboard=None,
      history=None,
      multiline=False,
      check_line_ending=True,
      key_bindings=None,
  ):
      """
      Create a Prompt, feed it with the given user input and return the CLI
      object.
  
      This returns a (result, Application) tuple.
      """
      # If the given text doesn't end with a newline, the interface won't finish.
      if check_line_ending:
          assert text.endswith("\r")
  
      with create_pipe_input() as inp:
          inp.send_text(text)
          session = PromptSession(
              input=inp,
              output=DummyOutput(),
              editing_mode=editing_mode,
              history=history,
              multiline=multiline,
              clipboard=clipboard,
              key_bindings=key_bindings,
          )
  
          _ = session.prompt()
          return session.default_buffer.document, session.app
  
imports: from __future__ import annotations
  from functools import partial
  import pytest
  from prompt_toolkit.clipboard import ClipboardData, InMemoryClipboard
  from prompt_toolkit.enums import EditingMode
  from prompt_toolkit.filters import ViInsertMode
  from prompt_toolkit.history import InMemoryHistory
  from prompt_toolkit.input.defaults import create_pipe_input
  from prompt_toolkit.input.vt100_parser import ANSI_SEQUENCES
  from prompt_toolkit.key_binding.bindings.named_commands import prefix_meta
  from prompt_toolkit.key_binding.key_bindings import KeyBindings
  from prompt_toolkit.output import DummyOutput
  from prompt_toolkit.shortcuts import PromptSession
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, key_bindings) and returns: session,  session