code: def _limit_context_infers(func):
      """
      This is for now the way how we limit type inference going wild. There are
      other ways to ensure recursion limits as well. This is mostly necessary
      because of instance (self) access that can be quite tricky to limit.
  
      I'm still not sure this is the way to go, but it looks okay for now and we
      can still go anther way in the future. Tests are there. ~ dave
      """
  
      def wrapper(context, *args, **kwargs):
          n = context.tree_node
          evaluator = context.evaluator
          try:
              evaluator.inferred_element_counts[n] += 1
              if evaluator.inferred_element_counts[n] > 300:
                  debug.warning(
                      "In context %s there were too many inferences.", n
                  )
                  return NO_CONTEXTS
          except KeyError:
              evaluator.inferred_element_counts[n] = 1
          return func(context, *args, **kwargs)
  
      return wrapper
  
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 1 for calling a global function with example usage: _limit_context_infers(func) and returns: wrapper, func, NO_CONTEXTS