code: def test_discrete_hmm_distribution():
      init_probs = torch.tensor([0.9, 0.1])
      trans_probs = torch.tensor(
          [
              [[0.9, 0.1], [0.1, 0.9]],  # noisy identity
              [[0.1, 0.9], [0.9, 0.1]],  # noisy flip
          ]
      )
      obs_dist = dist.Normal(torch.tensor([0.0, 1.0]), 0.1)
      hmm = dist.DiscreteHMM(
          init_probs.log(), trans_probs.log(), obs_dist
      )
      actual = hmm.sample([1000000]).mean(0)
      expected = torch.tensor(
          [0.1 * 0.9 + 0.9 * 0.1, 0.9**3 + 3 * 0.9 * 0.1**2]
      )
      assert_close(actual, expected, atol=1e-3)
  
imports: import logging
  import operator
  from functools import reduce
  import opt_einsum
  import pytest
  import torch
  import pyro
  import pyro.distributions
  from pyro.distributions.hmm import _sequential_gamma_gaussian_tensordot, _sequential_logmatmulexp
  from pyro.distributions.util import broadcast_shape
  from pyro.infer import TraceEnum_ELBO, config_enumerate
  from pyro.ops.gamma_gaussian import gamma_and_mvn_to_gamma_gaussian, gamma_gaussian_tensordot, matrix_and_mvn_to_gamma_gaussian
  from pyro.ops.gaussian import gaussian_tensordot, matrix_and_mvn_to_gaussian, mvn_to_gaussian
  from pyro.ops.indexing import Vindex
  from tests.common import assert_close
  from tests.ops.gamma_gaussian import assert_close_gamma_gaussian, random_gamma, random_gamma_gaussian
  from tests.ops.gaussian import random_mvn
label_desc: Use image node_id 10 for calling a global function with example usage: test_discrete_hmm_distribution() without return types