code: def get_template_locals(
      real_locals: t.Mapping[str, t.Any]
  ) -> t.Dict[str, t.Any]:
      """Based on the runtime locals, get the context that would be
      available at that point in the template.
      """
      # Start with the current template context.
      ctx: "t.Optional[Context]" = real_locals.get("context")
  
      if ctx is not None:
          data: t.Dict[str, t.Any] = ctx.get_all().copy()
      else:
          data = {}
  
      # Might be in a derived context that only sets local variables
      # rather than pushing a context. Local variables follow the scheme
      # l_depth_name. Find the highest-depth local that has a value for
      # each name.
      local_overrides: t.Dict[str, t.Tuple[int, t.Any]] = {}
  
      for name, value in real_locals.items():
          if not name.startswith("l_") or value is missing:
              # Not a template variable, or no longer relevant.
              continue
  
          try:
              _, depth_str, name = name.split("_", 2)
              depth = int(depth_str)
          except ValueError:
              continue
  
          cur_depth = local_overrides.get(name, (-1,))[0]
  
          if cur_depth < depth:
              local_overrides[name] = (depth, value)
  
      # Modify the context with any derived context.
      for name, (_, value) in local_overrides.items():
          if value is missing:
              data.pop(name, None)
          else:
              data[name] = value
  
      return data
  
file_path: catboost/contrib/python/Jinja2/py3/jinja2/debug.py
imports: import sys
  import typing
  from types import CodeType
  from types import TracebackType
  from .exceptions import TemplateSyntaxError
  from .utils import internal_code
  from .utils import missing
label_desc: Use image node_id 3 for calling a global function with example usage: get_template_locals(real_locals) and returns: data