code: def test_hmm_smoke(length, temperature):
      # 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.infer_discrete(
          infer.config_enumerate(hmm), 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)))
      )
  
file_path: pyro/tests/contrib/funsor/test_infer_discrete.py
imports: import logging
  import os
  import pyroapi
  import pytest
  import torch
  from pyro.infer.autoguide import AutoNormal
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_hmm_smoke(length, temperature) and returns: states,  data