code: def _sample_posterior(
      model,
      first_available_dim,
      temperature,
      strict_enumeration_warning,
      *args,
      **kwargs,
  ):
      # For internal use by infer_discrete.
  
      # Create an enumerated trace.
      with poutine.block(), EnumMessenger(first_available_dim):
          enum_trace = poutine.trace(model).get_trace(*args, **kwargs)
      enum_trace = prune_subsample_sites(enum_trace)
      enum_trace.compute_log_prob()
      enum_trace.pack_tensors()
  
      return _sample_posterior_from_trace(
          model,
          enum_trace,
          temperature,
          strict_enumeration_warning,
          *args,
          **kwargs,
      )
  
imports: import functools
  import warnings
  from collections import OrderedDict
  from opt_einsum import shared_intermediates
  import pyro.ops.packed
  from pyro import poutine
  from pyro.infer.traceenum_elbo import TraceEnum_ELBO
  from pyro.ops.contract import contract_tensor_tree
  from pyro.ops.einsum.adjoint import require_backward
  from pyro.ops.rings import MapRing, SampleRing
  from pyro.poutine.enum_messenger import EnumMessenger
  from pyro.poutine.replay_messenger import ReplayMessenger
  from pyro.poutine.util import prune_subsample_sites
  from pyro.util import jit_iter
label_desc: Use image node_id 2 for calling a global function with example usage: _sample_posterior(model, first_available_dim, temperature, strict_enumeration_warning) and returns: _sample_posterior_from_trace