code: def get_user_scope(module_context, position):
      """
      Returns the scope in which the user resides. This includes flows.
      """
      user_stmt = get_statement_of_position(
          module_context.tree_node, position
      )
      if user_stmt is None:
  
          def scan(scope):
              for s in scope.children:
                  if s.start_pos <= position <= s.end_pos:
                      if isinstance(
                          s, (tree.Scope, tree.Flow)
                      ) or s.type in ("async_stmt", "async_funcdef"):
                          return scan(s) or s
                      elif s.type in ("suite", "decorated"):
                          return scan(s)
              return None
  
          scanned_node = scan(module_context.tree_node)
          if scanned_node:
              return module_context.create_context(
                  scanned_node, node_is_context=True
              )
          return module_context
      else:
          return module_context.create_context(user_stmt)
  
imports: from parso.python.token import PythonTokenTypes
  from parso.python import tree
  from parso.tree import search_ancestor, Leaf
  from jedi._compatibility import Parameter
  from jedi import debug
  from jedi import settings
  from jedi.api import classes
  from jedi.api import helpers
  from jedi.evaluate import imports
  from jedi.api import keywords
  from jedi.evaluate.helpers import evaluate_call_of_leaf
  from jedi.evaluate.filters import get_global_filters
  from jedi.parser_utils import get_statement_of_position
label_desc: Use image node_id 3 for calling a global function with example usage: get_user_scope(module_context, position) and returns: module_context, module_context, None, module_context, unknown, scan