class_docstr: Replay regular sample sites in addition to uncollapsing any collapsed
  conjugate sites.
class_docstr_tok: ["Replay","regular","sample","sites","in","addition","to","uncollapsing","any","collapsed","conjugate","sites","."]
code: def _pyro_sample(self, msg):
      is_collapsible = getattr(msg["fn"], "collapsible", False)
      # uncollapse conjugate sites.
      if is_collapsible:
          conj_node, parent = None, None
          for site_name in (
              self.trace.observation_nodes + self.trace.stochastic_nodes
          ):
              parent = getattr(
                  self.trace.nodes[site_name]["fn"], "parent", None
              )
              if (
                  parent is not None
                  and parent._latent.site_name == msg["name"]
              ):
                  conj_node = self.trace.nodes[site_name]
                  break
          assert (
              conj_node is not None
          ), "Collapsible latent site `{}` with no corresponding conjugate site.".format(
              msg["name"]
          )
          msg["fn"] = parent.posterior(conj_node["value"])
          msg["value"] = msg["fn"].sample()
      # regular replay behavior.
      else:
          name = msg["name"]
          if name in self.trace:
              guide_msg = self.trace.nodes[name]
              if msg["is_observed"]:
                  return None
              if guide_msg["type"] != "sample":
                  raise RuntimeError(
                      "site {} must be sample in trace".format(name)
                  )
              msg["done"] = True
              msg["value"] = guide_msg["value"]
              msg["infer"] = guide_msg["infer"]
  
imports: from collections import defaultdict
  import torch
  import pyro.distributions
  from pyro import poutine
  from pyro.distributions.util import sum_leftmost
  from pyro.poutine.messenger import Messenger
  from pyro.poutine.util import site_is_subsample
label_desc: Use image node_id 2 for calling the UncollapseConjugateMessenger obj's underlying member method code with example usage: obj._pyro_sample(msg) and returns: None