code: def _get_all_caller_variables() -> dict[str, Any]:
      """Get all local and global variables from caller's frame."""
      pkg_dir = Path(__file__).parent.parent
  
      # https://stackoverflow.com/questions/17407119/python-inspect-stack-is-slow
      frame = inspect.currentframe()
      n = 0
      try:
          while frame:
              fname = inspect.getfile(frame)
              if fname.startswith(str(pkg_dir)):
                  frame = frame.f_back
                  n += 1
              else:
                  break
          variables: dict[str, Any]
          if frame is None:
              variables = {}
          else:
              variables = {**frame.f_locals, **frame.f_globals}
      finally:
          # https://docs.python.org/3/library/inspect.html
          # > Though the cycle detector will catch these, destruction of the frames
          # > (and local variables) can be made deterministic by removing the cycle
          # > in a finally clause.
          del frame
      return variables
  
imports: from __future__ import annotations
  import datetime
  import dis
  import inspect
  import re
  import sys
  import warnings
  from bisect import bisect_left
  from collections import defaultdict
  from dis import get_instructions
  from inspect import signature
  from itertools import count, zip_longest
  from pathlib import Path
  from typing import TYPE_CHECKING, AbstractSet, Any, Callable, ClassVar, Iterator, Literal, NamedTuple, Union
label_desc: Use image node_id 1 for calling a global function with example usage: _get_all_caller_variables() and returns: variables