code: def _get_code_for_stack(code_lines, module_node, position):
      leaf = module_node.get_leaf_for_position(
          position, include_prefixes=True
      )
      # It might happen that we're on whitespace or on a comment. This means
      # that we would not get the right leaf.
      if leaf.start_pos >= position:
          # If we're not on a comment simply get the previous leaf and proceed.
          leaf = leaf.get_previous_leaf()
          if leaf is None:
              return u("")  # At the beginning of the file.
  
      is_after_newline = leaf.type == "newline"
      while leaf.type == "newline":
          leaf = leaf.get_previous_leaf()
          if leaf is None:
              return u("")
  
      if leaf.type == "error_leaf" or leaf.type == "string":
          if leaf.start_pos[0] < position[0]:
              # On a different line, we just begin anew.
              return u("")
  
          # Error leafs cannot be parsed, completion in strings is also
          # impossible.
          raise OnErrorLeaf(leaf)
      else:
          user_stmt = leaf
          while True:
              if user_stmt.parent.type in (
                  "file_input",
                  "suite",
                  "simple_stmt",
              ):
                  break
              user_stmt = user_stmt.parent
  
          if is_after_newline:
              if user_stmt.start_pos[1] > position[1]:
                  # This means that it's actually a dedent and that means that we
                  # start without context (part of a suite).
                  return u("")
  
          # This is basically getting the relevant lines.
          return _get_code(
              code_lines, user_stmt.get_start_pos_of_prefix(), position
          )
  
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 4 for calling a global function with example usage: _get_code_for_stack(code_lines, module_node, position) and returns: _get_code, u, u, u, u