code: def test_independent_hmm_shape(
      skew, batch_shape, duration, hidden_dim, obs_dim
  ):
      base_batch_shape = batch_shape + (obs_dim,)
      stability = dist.Uniform(0.5, 2).sample(base_batch_shape)
      init_dist = random_stable(
          base_batch_shape + (hidden_dim,),
          stability.unsqueeze(-1),
          skew=skew,
      ).to_event(1)
      trans_mat = torch.randn(
          base_batch_shape + (duration, hidden_dim, hidden_dim)
      )
      trans_dist = random_stable(
          base_batch_shape + (duration, hidden_dim),
          stability.unsqueeze(-1).unsqueeze(-1),
          skew=skew,
      ).to_event(1)
      obs_mat = torch.randn(
          base_batch_shape + (duration, hidden_dim, 1)
      )
      obs_dist = random_stable(
          base_batch_shape + (duration, 1),
          stability.unsqueeze(-1).unsqueeze(-1),
          skew=skew,
      ).to_event(1)
      hmm = dist.LinearHMM(
          init_dist,
          trans_mat,
          trans_dist,
          obs_mat,
          obs_dist,
          duration=duration,
      )
      assert hmm.batch_shape == base_batch_shape
      assert hmm.event_shape == (duration, 1)
  
      hmm = dist.IndependentHMM(hmm)
      assert hmm.batch_shape == batch_shape
      assert hmm.event_shape == (duration, obs_dim)
  
      def model(data=None):
          with pyro.plate_stack("plates", batch_shape):
              return pyro.sample("x", hmm, obs=data)
  
      data = torch.randn(duration, obs_dim)
      rep = SymmetricStableReparam() if skew == 0 else StableReparam()
      with poutine.trace() as tr:
          with poutine.reparam(
              config={"x": LinearHMMReparam(rep, rep, rep)}
          ):
              model(data)
      assert isinstance(tr.trace.nodes["x"]["fn"], dist.IndependentHMM)
      tr.trace.compute_log_prob()
  
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 6 for calling a global function with example usage: test_independent_hmm_shape(skew, batch_shape, duration, hidden_dim, obs_dim) and returns: pyro