code: def function_ast_to_function(fn_ast, stacklevel=1):
      # Validate
      assert isinstance(fn_ast, ast.Module)
      fndef_ast = fn_ast.body[0]
      assert isinstance(fndef_ast, ast.FunctionDef)
  
      # Compile AST to code object
      code = compile_function_ast(fn_ast)
  
      # Evaluate the function in a scope that includes the globals and
      # locals of desired frame.
      current_frame = inspect.currentframe()
      eval_frame = current_frame
      for _ in range(stacklevel):
          eval_frame = eval_frame.f_back
  
      eval_locals = eval_frame.f_locals
      eval_globals = eval_frame.f_globals
      del current_frame
      scope = copy.copy(eval_globals)
      scope.update(eval_locals)
  
      # Evaluate function in scope
      eval(code, scope)
  
      # Return the newly evaluated function from the scope
      return scope[fndef_ast.name]
  
imports: import re
  import copy
  import inspect
  import ast
  import textwrap
label_desc: Use image node_id 4 for calling a global function with example usage: function_ast_to_function(fn_ast, stacklevel) and returns: scope