code: def infer_discrete(
      fn=None,
      first_available_dim=None,
      temperature=1,
      *,
      strict_enumeration_warning=True,
  ):
      """
      A poutine that samples discrete sites marked with
      ``site["infer"]["enumerate"] = "parallel"`` from the posterior,
      conditioned on observations.
  
      Example::
  
          @infer_discrete(first_available_dim=-1, temperature=0)
          @config_enumerate
          def viterbi_decoder(data, hidden_dim=10):
              transition = 0.3 / hidden_dim + 0.7 * torch.eye(hidden_dim)
              means = torch.arange(float(hidden_dim))
              states = [0]
              for t in pyro.markov(range(len(data))):
                  states.append(pyro.sample("states_{}".format(t),
                                            dist.Categorical(transition[states[-1]])))
                  pyro.sample("obs_{}".format(t),
                              dist.Normal(means[states[-1]], 1.),
                              obs=data[t])
              return states  # returns maximum likelihood states
  
      .. warning: The ``log_prob``s of the inferred model's trace are not
          meaningful, and may be changed future release.
  
      :param fn: a stochastic function (callable containing Pyro primitive calls)
      :param int first_available_dim: The first tensor dimension (counting
          from the right) that is available for parallel enumeration. This
          dimension and all dimensions left may be used internally by Pyro.
          This should be a negative integer.
      :param int temperature: Either 1 (sample via forward-filter backward-sample)
          or 0 (optimize via Viterbi-like MAP inference). Defaults to 1 (sample).
      :param bool strict_enumeration_warning: Whether to warn in case no
          enumerated sample sites are found. Defalts to True.
      """
      assert first_available_dim < 0, first_available_dim
      if fn is None:  # support use as a decorator
          return functools.partial(
              infer_discrete,
              first_available_dim=first_available_dim,
              temperature=temperature,
          )
      return functools.partial(
          _sample_posterior,
          fn,
          first_available_dim,
          temperature,
          strict_enumeration_warning,
      )
  
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 4 for calling a global function with example usage: infer_discrete(fn, first_available_dim, temperature) and returns: functools, functools