class_docstr: EXPERIMENTAL Collapses all sites in the context by lazily sampling and
  attempting to use conjugacy relations. If no conjugacy is known this will
  fail. Code using the results of sample sites must be written to accept
  Funsors rather than Tensors. This requires ``funsor`` to be installed.
  
  .. warning:: This is not compatible with automatic guessing of
      ``max_plate_nesting``. If any plates appear within the collapsed
      context, you should manually declare ``max_plate_nesting`` to your
      inference algorithm (e.g. ``Trace_ELBO(max_plate_nesting=1)``).
class_docstr_tok: ["EXPERIMENTAL","Collapses","all","sites","in","the","context","by","lazily","sampling","and","attempting","to","use","conjugacy","relations",".","If","no","conjugacy","is","known","this","will","fail",".","Code","using","the","results","of","sample","sites","must","be","written","to","accept","Funsors","rather","than","Tensors",".","This","requires","``","funsor","``","to","be","installed",".","..","warning",":",":","This","is","not","compatible","with","automatic","guessing","of","``","max_plate_nesting","``",".","If","any","plates","appear","within","the","collapsed","context",",","you","should","manually","declare","``","max_plate_nesting","``","to","your","inference","algorithm","(","e.g",".","``","Trace_ELBO","(","max_plate_nesting=1",")","``",")","."]
code: def _pyro_barrier(self, msg: "Message") -> None:
      # Get log_prob and record factor.
      name, log_prob, log_joint, sampled_vars = self._get_log_prob()
      self._block = True
      pyro.factor(name, log_prob.data)
      self._block = False
  
      # Sample
      if sampled_vars:
          samples = log_joint.sample(sampled_vars)
          deltas = _extract_deltas(samples)
          samples = {
              name: point.data for name, (point, _) in deltas.terms
          }
      else:
          samples = {}
  
      # Update value.
      assert len(msg["args"]) == 1
      value = msg["args"][0]
      value = _substitute(value, samples)
      msg["value"] = value
  
imports: from functools import reduce, singledispatch
  from typing import TYPE_CHECKING, FrozenSet, Tuple
  from typing_extensions import Self
  import pyro
  from pyro.distributions.distribution import COERCIONS
  from pyro.ops.linalg import ignore_torch_deprecation_warnings
  from pyro.poutine.runtime import _PYRO_STACK
  from pyro.poutine.trace_messenger import TraceMessenger
  from pyro.poutine.util import site_is_subsample
label_desc: Use image node_id 5 for calling the CollapseMessenger obj's underlying member method code with example usage: obj._pyro_barrier(msg) without return types