class_docstr: Implements forward filtering / backward sampling for sampling
  from the joint posterior distribution
class_docstr_tok: ["Implements","forward","filtering","\/","backward","sampling","for","sampling","from","the","joint","posterior","distribution"]
code: def _pyro_sample(self, msg):
      enum_msg = self.enum_trace.nodes.get(msg["name"])
      if enum_msg is None:
          return
      enum_symbol = enum_msg["infer"].get("_enumerate_symbol")
      if enum_symbol is None:
          return
      enum_dim = enum_msg["infer"]["_enumerate_dim"]
      with shared_intermediates(self.cache):
          ordinal = _find_ordinal(self.enum_trace, msg)
          logits = contract_to_tensor(
              self.log_factors,
              self.sum_dims,
              target_ordinal=ordinal,
              target_dims={enum_symbol},
              cache=self.cache,
          )
          logits = packed.unpack(logits, self.enum_trace.symbol_to_dim)
          logits = logits.unsqueeze(-1).transpose(-1, enum_dim - 1)
          while logits.shape[0] == 1:
              logits = logits.squeeze(0)
      msg["fn"] = _make_dist(msg["fn"], logits)
  
imports: import queue
  import warnings
  import weakref
  from collections import OrderedDict
  import torch
  from opt_einsum import shared_intermediates
  import pyro
  import pyro.distributions
  import pyro.ops.jit
  import pyro.poutine
  from pyro.distributions.util import is_identically_zero
  from pyro.infer.elbo import ELBO
  from pyro.infer.enum import get_importance_trace, iter_discrete_escape, iter_discrete_extend
  from pyro.infer.util import Dice, is_validation_enabled
  from pyro.ops import packed
  from pyro.ops.contract import contract_tensor_tree, contract_to_tensor
  from pyro.ops.rings import SampleRing
  from pyro.poutine.enum_messenger import EnumMessenger
  from pyro.util import check_traceenum_requirements, ignore_jit_warnings, warn_if_nan
label_desc: Use image node_id 4 for calling the BackwardSampleMessenger obj's underlying member method code with example usage: obj._pyro_sample(msg) without return types