code: def test_hmm_smoke(infer, temperature, length):
      # This should match the example in the infer_discrete docstring.
      def hmm(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]]),
                  )
              )
              data[t] = pyro.sample(
                  "obs_{}".format(t),
                  dist.Normal(means[states[-1]], 1.0),
                  obs=data[t],
              )
          return states, data
  
      true_states, data = hmm([None] * length)
      assert len(data) == length
      assert len(true_states) == 1 + len(data)
  
      decoder = infer(
          config_enumerate(hmm),
          first_available_dim=-1,
          temperature=temperature,
      )
      inferred_states, _ = decoder(data)
      assert len(inferred_states) == len(true_states)
  
      logger.info("true states: {}".format(list(map(int, true_states))))
      logger.info(
          "inferred states: {}".format(list(map(int, inferred_states)))
      )
  
imports: import logging
  import math
  import warnings
  import pytest
  import torch
  from torch.autograd import grad
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer import TraceEnum_ELBO
  from pyro.infer.discrete import TraceEnumSample_ELBO, infer_discrete
  from pyro.infer.enum import config_enumerate
  from tests.common import assert_equal
label_desc: Use image node_id 8 for calling a global function with example usage: test_hmm_smoke(infer, temperature, length) and returns: states,  data