code: def test_stable_hmm_distribution(
      stability, skew, duration, hidden_dim, obs_dim
  ):
      init_dist = random_stable(
          (hidden_dim,), stability, skew=skew
      ).to_event(1)
      trans_mat = torch.randn(duration, hidden_dim, hidden_dim)
      trans_dist = random_stable(
          (duration, hidden_dim), stability, skew=skew
      ).to_event(1)
      obs_mat = torch.randn(duration, hidden_dim, obs_dim)
      obs_dist = random_stable(
          (duration, obs_dim), stability, skew=skew
      ).to_event(1)
      hmm = dist.LinearHMM(
          init_dist,
          trans_mat,
          trans_dist,
          obs_mat,
          obs_dist,
          duration=duration,
      )
  
      num_samples = 200000
      expected_samples = hmm.sample([num_samples]).reshape(
          num_samples, duration * obs_dim
      )
      expected_loc, expected_scale, expected_corr = get_hmm_moments(
          expected_samples
      )
  
      rep = SymmetricStableReparam() if skew == 0 else StableReparam()
      with pyro.plate("samples", num_samples):
          with poutine.reparam(
              config={"x": LinearHMMReparam(rep, rep, rep)}
          ):
              actual_samples = pyro.sample("x", hmm).reshape(
                  num_samples, duration * obs_dim
              )
      actual_loc, actual_scale, actual_corr = get_hmm_moments(
          actual_samples
      )
  
      assert_close(actual_loc, expected_loc, atol=0.05, rtol=0.05)
      assert_close(actual_scale, expected_scale, atol=0.05, rtol=0.05)
      assert_close(actual_corr, expected_corr, atol=0.01)
  
file_path: pyro/tests/infer/reparam/test_hmm.py
imports: import pytest
  import torch
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer.reparam import LinearHMMReparam, StableReparam, StudentTReparam, SymmetricStableReparam
  from tests.common import assert_close
  from tests.ops.gaussian import random_mvn
  from .util import check_init_reparam
label_desc: Use image node_id 8 for calling a global function with example usage: test_stable_hmm_distribution(stability, skew, duration, hidden_dim, obs_dim) without return types