code: def tree_name_to_contexts(evaluator, context, tree_name):
      context_set = ContextSet()
      module_node = context.get_root_context().tree_node
      if module_node is not None:
          names = module_node.get_used_names().get(tree_name.value, [])
          for name in names:
              expr_stmt = name.parent
  
              correct_scope = (
                  parser_utils.get_parent_scope(name)
                  == context.tree_node
              )
  
              if (
                  expr_stmt.type == "expr_stmt"
                  and expr_stmt.children[1].type == "annassign"
                  and correct_scope
              ):
                  context_set |= _evaluate_for_annotation(
                      context, expr_stmt.children[1].children[1]
                  )
  
      if context_set:
          return context_set
  
      types = []
      node = tree_name.get_definition(import_name_always=True)
      if node is None:
          node = tree_name.parent
          if node.type == "global_stmt":
              context = evaluator.create_context(context, tree_name)
              finder = NameFinder(
                  evaluator, context, context, tree_name.value
              )
              filters = finder.get_filters(search_global=True)
              # For global_stmt lookups, we only need the first possible scope,
              # which means the function itself.
              filters = [next(filters)]
              return finder.find(filters, attribute_lookup=False)
          elif node.type not in ("import_from", "import_name"):
              raise ValueError("Should not happen. type: %s", node.type)
  
      typ = node.type
      if typ == "for_stmt":
          types = pep0484.find_type_from_comment_hint_for(
              context, node, tree_name
          )
          if types:
              return types
      if typ == "with_stmt":
          types = pep0484.find_type_from_comment_hint_with(
              context, node, tree_name
          )
          if types:
              return types
  
      if typ in ("for_stmt", "comp_for"):
          try:
              types = context.predefined_names[node][tree_name.value]
          except KeyError:
              cn = ContextualizedNode(context, node.children[3])
              for_types = iterate_contexts(
                  cn.infer(),
                  contextualized_node=cn,
                  is_async=node.parent.type == "async_stmt",
              )
              c_node = ContextualizedName(context, tree_name)
              types = check_tuple_assignments(
                  evaluator, c_node, for_types
              )
      elif typ == "expr_stmt":
          types = _remove_statements(
              evaluator, context, node, tree_name
          )
      elif typ == "with_stmt":
          context_managers = context.eval_node(
              node.get_test_node_from_name(tree_name)
          )
          enter_methods = context_managers.py__getattribute__(
              "__enter__"
          )
          return enter_methods.execute_evaluated()
      elif typ in ("import_from", "import_name"):
          types = imports.infer_import(context, tree_name)
      elif typ in ("funcdef", "classdef"):
          types = _apply_decorators(context, node)
      elif typ == "try_stmt":
          # TODO an exception can also be a tuple. Check for those.
          # TODO check for types that are not classes and add it to
          # the static analysis report.
          exceptions = context.eval_node(
              tree_name.get_previous_sibling().get_previous_sibling()
          )
          types = exceptions.execute_evaluated()
      else:
          raise ValueError("Should not happen. type: %s" % typ)
      return types
  
imports: import copy
  from parso.python import tree
  from jedi._compatibility import force_unicode, unicode
  from jedi import debug
  from jedi import parser_utils
  from jedi.evaluate.base_context import ContextSet, NO_CONTEXTS, ContextualizedNode, ContextualizedName, iterator_to_context_set, iterate_contexts
  from jedi.evaluate import compiled
  from jedi.evaluate import pep0484
  from jedi.evaluate import recursion
  from jedi.evaluate import helpers
  from jedi.evaluate import analysis
  from jedi.evaluate import imports
  from jedi.evaluate import arguments
  from jedi.evaluate.pep0484 import _evaluate_for_annotation
  from jedi.evaluate.context import ClassContext, FunctionContext
  from jedi.evaluate.context import iterable
  from jedi.evaluate.context import TreeInstance, CompiledInstance
  from jedi.evaluate.finder import NameFinder
  from jedi.evaluate.helpers import is_string, is_literal, is_number, is_compiled
  from jedi.evaluate.compiled.access import COMPARISON_OPERATORS
label_desc: Use image node_id 17 for calling a global function with example usage: tree_name_to_contexts(evaluator, context, tree_name) and returns: types, context_set, finder, types, types, enter_methods