code: def apply_stack(initial_msg: Message) -> None:
      """
      Execute the effect stack at a single site according to the following scheme:
  
          1. For each ``Messenger`` in the stack from bottom to top,
             execute ``Messenger._process_message`` with the message;
             if the message field "stop" is True, stop;
             otherwise, continue
          2. Apply default behavior (``default_process_message``) to finish remaining site execution
          3. For each ``Messenger`` in the stack from top to bottom,
             execute ``_postprocess_message`` to update the message and internal messenger state with the site results
          4. If the message field "continuation" is not ``None``, call it with the message
  
      :param dict initial_msg: the starting version of the trace site
      :returns: ``None``
      """
      stack = _PYRO_STACK
      # TODO check at runtime if stack is valid
  
      # msg is used to pass information up and down the stack
      msg = initial_msg
  
      pointer = 0
      # go until time to stop?
      for frame in reversed(stack):
          pointer = pointer + 1
  
          frame._process_message(msg)
  
          if msg["stop"]:
              break
  
      default_process_message(msg)
  
      for frame in stack[-pointer:]:
          frame._postprocess_message(msg)
  
      cont = msg["continuation"]
      if cont is not None:
          cont(msg)
  
imports: import functools
  from typing import TYPE_CHECKING, Callable, Dict, Generic, List, Optional, Set, Tuple, TypeVar, Union, overload
  import torch
  from typing_extensions import Literal, ParamSpec, TypedDict
  from pyro.params.param_store import _MODULE_NAMESPACE_DIVIDER, ParamStoreDict
label_desc: Use image node_id 2 for calling a global function with example usage: apply_stack(initial_msg) without return types