class_docstr: Execution trace poutine.
  
  A TraceHandler records the input and output to every Pyro primitive
  and stores them as a site in a Trace().
  This should, in theory, be sufficient information for every inference algorithm
  (along with the implicit computational graph in the Variables?)
  
  We can also use this for visualization.
docstr: Runs the stochastic function stored in this poutine,
  with additional side effects.
  
  Resets self.trace to an empty trace,
  installs itself on the global execution stack,
  runs self.fn with the given arguments,
  uninstalls itself from the global execution stack,
  stores the arguments and return value of the function in special sites,
  and returns self.fn's return value
docstr_tok: ["Runs","the","stochastic","function","stored","in","this","poutine",",","with","additional","side","effects",".","Resets","self.trace","to","an","empty","trace",",","installs","itself","on","the","global","execution","stack",",","runs","self.fn","with","the","given","arguments",",","uninstalls","itself","from","the","global","execution","stack",",","stores","the","arguments","and","return","value","of","the","function","in","special","sites",",","and","returns","self.fn","'s","return","value"]
code: def __call__(self, *args, **kwargs) -> Any:
      """
      Runs the stochastic function stored in this poutine,
      with additional side effects.
  
      Resets self.trace to an empty trace,
      installs itself on the global execution stack,
      runs self.fn with the given arguments,
      uninstalls itself from the global execution stack,
      stores the arguments and return value of the function in special sites,
      and returns self.fn's return value
      """
      with self.msngr:
          self.msngr.trace.add_node(
              "_INPUT",
              name="_INPUT",
              type="args",
              args=args,
              kwargs=kwargs,
          )
          try:
              ret = self.fn(*args, **kwargs)
          except (ValueError, RuntimeError) as e:
              exc_type, exc_value, traceback = sys.exc_info()
              shapes = self.msngr.trace.format_shapes()
              assert exc_type is not None
              exc = exc_type("{}\n{}".format(exc_value, shapes))
              exc = exc.with_traceback(traceback)
              raise exc from e
          self.msngr.trace.add_node(
              "_RETURN", name="_RETURN", type="return", value=ret
          )
      return ret
  
imports: import sys
  from typing import TYPE_CHECKING, Any, Callable, Literal, Optional
  from typing_extensions import Self
  from pyro.poutine.messenger import Messenger
  from pyro.poutine.trace_struct import Trace
  from pyro.poutine.util import site_is_subsample
label_desc: Use image node_id 2 for calling the TraceHandler obj's underlying member method code with example usage: obj.__call__() and returns: ret