code: def accept_token(event: KeyPressEvent):
      """Fill partial autosuggestion by token"""
      b = event.current_buffer
      suggestion = b.suggestion
  
      if suggestion:
          prefix = _get_query(b.document)
          text = prefix + suggestion.text
  
          tokens: List[Optional[str]] = [None, None, None]
          substrings = [""]
          i = 0
  
          for token in generate_tokens(StringIO(text).readline):
              if token.type == tokenize.NEWLINE:
                  index = len(text)
              else:
                  index = text.index(token[1], len(substrings[-1]))
              substrings.append(text[:index])
              tokenized_so_far = substrings[-1]
              if tokenized_so_far.startswith(prefix):
                  if i == 0 and len(tokenized_so_far) > len(prefix):
                      tokens[0] = tokenized_so_far[len(prefix) :]
                      substrings.append(tokenized_so_far)
                      i += 1
                  tokens[i] = token[1]
                  if i == 2:
                      break
                  i += 1
  
          if tokens[0]:
              to_insert: str
              insert_text = substrings[-2]
              if tokens[1] and len(tokens[1]) == 1:
                  insert_text = substrings[-1]
              to_insert = insert_text[len(prefix) :]
              b.insert_text(to_insert)
              return
  
      nc.forward_word(event)
  
imports: import re
  import tokenize
  from io import StringIO
  from typing import Callable, List, Optional, Union, Generator, Tuple
  import warnings
  from prompt_toolkit.buffer import Buffer
  from prompt_toolkit.key_binding import KeyPressEvent
  from prompt_toolkit.key_binding.bindings import named_commands
  from prompt_toolkit.auto_suggest import AutoSuggestFromHistory, Suggestion
  from prompt_toolkit.document import Document
  from prompt_toolkit.history import History
  from prompt_toolkit.shortcuts import PromptSession
  from prompt_toolkit.layout.processors import Processor, Transformation, TransformationInput
  from IPython.core.getipython import get_ipython
  from IPython.utils.tokenutil import generate_tokens
  from .filters import pass_through
label_desc: Use image node_id 15 for calling a global function with example usage: accept_token(event) without return types