class_docstr: Adaptor to provide IPython completions to prompt_toolkit
code: def get_completions(self, document, complete_event):
      if not document.current_line.strip():
          return
      # Some bits of our completion system may print stuff (e.g. if a module
      # is imported). This context manager ensures that doesn't interfere with
      # the prompt.
  
      with patch_stdout(), provisionalcompleter():
          body = document.text
          cursor_row = document.cursor_position_row
          cursor_col = document.cursor_position_col
          cursor_position = document.cursor_position
          offset = cursor_to_position(body, cursor_row, cursor_col)
          try:
              yield from self._get_completions(
                  body, offset, cursor_position, self.ipy_completer
              )
          except Exception as e:
              try:
                  exc_type, exc_value, exc_tb = sys.exc_info()
                  traceback.print_exception(exc_type, exc_value, exc_tb)
              except AttributeError:
                  print("Unrecoverable Error in completions")
  
imports: import unicodedata
  from wcwidth import wcwidth
  from IPython.core.completer import provisionalcompleter, cursor_to_position, _deduplicate_completions
  from prompt_toolkit.completion import Completer, Completion
  from prompt_toolkit.lexers import Lexer
  from prompt_toolkit.lexers import PygmentsLexer
  from prompt_toolkit.patch_stdout import patch_stdout
  import pygments.lexers
  import os
  import sys
  import traceback
label_desc: Use image node_id 3 for calling the IPythonPTCompleter obj's underlying member method code with example usage: obj.get_completions(document, complete_event) without return types