code: def setUp(self):
      # simple Gaussian-emission HMM
      def model():
          p_latent = pyro.param("p1", torch.tensor([[0.7], [0.3]]))
          p_obs = pyro.param("p2", torch.tensor([[0.9], [0.1]]))
  
          latents = [torch.ones(1, 1)]
          observes = []
          for t in range(self.model_steps):
              latents.append(
                  pyro.sample(
                      "latent_{}".format(str(t)),
                      Bernoulli(
                          torch.index_select(
                              p_latent, 0, latents[-1].view(-1).long()
                          )
                      ),
                  )
              )
  
              observes.append(
                  pyro.sample(
                      "observe_{}".format(str(t)),
                      Bernoulli(
                          torch.index_select(
                              p_obs, 0, latents[-1].view(-1).long()
                          )
                      ),
                      obs=self.data[t],
                  )
              )
          return torch.sum(torch.cat(latents))
  
      self.model_steps = 3
      self.data = [torch.ones(1, 1) for _ in range(self.model_steps)]
      self.model = model
  
file_path: pyro/tests/infer/test_sampling.py
imports: from unittest import TestCase
  import pytest
  import torch
  import pyro
  import pyro.infer
  from pyro.distributions import Bernoulli, Normal
  from pyro.infer import EmpiricalMarginal
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling the HMMSamplingTestCase obj's underlying member method code with example usage: obj.setUp() and returns: torch