class_docstr: Given a callable that contains Pyro primitive calls,
  return a callable that runs the original, reusing the values at sites in trace
  at those sites in the new trace
  
  Consider the following Pyro program:
  
      >>> def model(x):
      ...     s = pyro.param("s", torch.tensor(0.5))
      ...     z = pyro.sample("z", dist.Normal(x, s))
      ...     return z ** 2
  
  ``replay`` makes ``sample`` statements behave as if they had sampled the values
  at the corresponding sites in the trace:
  
      >>> old_trace = pyro.poutine.trace(model).get_trace(1.0)
      >>> replayed_model = pyro.poutine.replay(model, trace=old_trace)
      >>> bool(replayed_model(0.0) == old_trace.nodes["_RETURN"]["value"])
      True
  
  :param fn: a stochastic function (callable containing Pyro primitive calls)
  :param trace: a :class:`~pyro.poutine.Trace` data structure to replay against
  :param params: dict of names of param sites and constrained values
      in fn to replay against
  :returns: a stochastic function decorated with a :class:`~pyro.poutine.replay_messenger.ReplayMessenger`
docstr: :param trace: a trace whose values should be reused
  
  Constructor.
  Stores trace in an attribute.
docstr_tok: [":","param","trace",":","a","trace","whose","values","should","be","reused","Constructor",".","Stores","trace","in","an","attribute","."]
code: def __init__(
      self,
      trace: Optional["Trace"] = None,
      params: Optional[Dict[str, "torch.Tensor"]] = None,
  ) -> None:
      """
      :param trace: a trace whose values should be reused
  
      Constructor.
      Stores trace in an attribute.
      """
      super().__init__()
      if trace is None and params is None:
          raise ValueError(
              "must provide trace or params to replay against"
          )
      self.trace = trace
      self.params = params
  
imports: from typing import TYPE_CHECKING, Dict, Optional
  from pyro.poutine.messenger import Messenger
label_desc: Use image node_id 1 to create a new ReplayMessenger object from inherited base classes: Messenger with example: obj = ReplayMessenger(trace, params)