class_docstr: Computes the log probability density of a trace (of a model with
  tree structure) that possibly contains discrete sample sites
  enumerated in parallel. This uses optimized `einsum` operations
  to marginalize out the the enumerated dimensions in the trace
  via :class:`~pyro.ops.contract.contract_to_tensor`.
  
  :param model_trace: execution trace from a static model.
  :param bool has_enumerable_sites: whether the trace contains any
      discrete enumerable sites.
  :param int max_plate_nesting: Optional bound on max number of nested
      :func:`pyro.plate` contexts.
class_docstr_tok: ["Computes","the","log","probability","density","of","a","trace","(","of","a","model","with","tree","structure",")","that","possibly","contains","discrete","sample","sites","enumerated","in","parallel",".","This","uses","optimized","`","einsum","`","operations","to","marginalize","out","the","the","enumerated","dimensions","in","the","trace","via",":","class",":","`","~pyro.ops.contract.contract_to_tensor","`",".",":","param","model_trace",":","execution","trace","from","a","static","model",".",":","param","bool","has_enumerable_sites",":","whether","the","trace","contains","any","discrete","enumerable","sites",".",":","param","int","max_plate_nesting",":","Optional","bound","on","max","number","of","nested",":","func",":","`","pyro.plate","`","contexts","."]
docstr: Populate the ordinals (set of ``CondIndepStack`` frames)
  and enum_dims for each sample site.
docstr_tok: ["Populate","the","ordinals","(","set","of","``","CondIndepStack","``","frames",")","and","enum_dims","for","each","sample","site","."]
code: def _populate_cache(self, model_trace):
      """
      Populate the ordinals (set of ``CondIndepStack`` frames)
      and enum_dims for each sample site.
      """
      if not self.has_enumerable_sites:
          return
      if self.max_plate_nesting is None:
          raise ValueError(
              "Finite value required for `max_plate_nesting` when model "
              "has discrete (enumerable) sites."
          )
      model_trace.compute_log_prob()
      model_trace.pack_tensors()
      for name, site in model_trace.nodes.items():
          if site["type"] == "sample" and not isinstance(
              site["fn"], _Subsample
          ):
              if is_validation_enabled():
                  check_site_shape(site, self.max_plate_nesting)
              self.ordering[name] = frozenset(
                  model_trace.plate_to_symbol[f.name]
                  for f in site["cond_indep_stack"]
                  if f.vectorized
              )
      self._enum_dims = set(model_trace.symbol_to_dim) - set(
          model_trace.plate_to_symbol.values()
      )
  
imports: import functools
  import traceback
  import warnings
  from collections import OrderedDict, defaultdict
  from functools import partial, reduce
  from itertools import product
  import torch
  from opt_einsum import shared_intermediates
  from torch.distributions import biject_to
  import pyro
  import pyro.poutine
  from pyro.distributions.util import broadcast_shape, logsumexp
  from pyro.infer import config_enumerate
  from pyro.infer.autoguide.initialization import InitMessenger, init_to_uniform
  from pyro.infer.util import is_validation_enabled
  from pyro.ops import stats
  from pyro.ops.contract import contract_to_tensor
  from pyro.ops.integrator import potential_grad
  from pyro.poutine.subsample_messenger import _Subsample
  from pyro.poutine.util import prune_subsample_sites
  from pyro.util import check_site_shape, ignore_jit_warnings
label_desc: Use image node_id 2 for calling the TraceEinsumEvaluator obj's underlying member method code with example usage: obj._populate_cache(model_trace) without return types