def METHOD_NAME(self, msg):
    # 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