code: def get_on_completion_name(module_node, lines, position):
      leaf = module_node.get_leaf_for_position(position)
      if leaf is None or leaf.type in ("string", "error_leaf"):
          # Completions inside strings are a bit special, we need to parse the
          # string. The same is true for comments and error_leafs.
          line = lines[position[0] - 1]
          # The first step of completions is to get the name
          return re.search(r"(?!\d)\w+$|$", line[: position[1]]).group(
              0
          )
      elif leaf.type not in ("name", "keyword"):
          return ""
  
      return leaf.value[: position[1] - leaf.start_pos[1]]
  
imports: import re
  from collections import namedtuple
  from textwrap import dedent
  from parso.python.parser import Parser
  from parso.python import tree
  from jedi._compatibility import u
  from jedi.evaluate.syntax_tree import eval_atom
  from jedi.evaluate.helpers import evaluate_call_of_leaf
  from jedi.evaluate.compiled import get_string_context_set
  from jedi.cache import call_signature_time_cache
label_desc: Use image node_id 2 for calling a global function with example usage: get_on_completion_name(module_node, lines, position) and returns: leaf, re, str