code: def test_ss_mle(dim, dist):
      base_dist = dist[0](
          *(torch.tensor(param).expand((dim,)) for param in dist[1])
      ).to_event(1)
  
      skewness_tar = _skewness(base_dist.event_shape)
      data = SineSkewed(base_dist, skewness_tar).sample((1000,))
  
      def model(data, batch_shape):
          skews = []
          for i in range(dim):
              skews.append(
                  pyro.param(
                      f"skew{i}",
                      0.5 * torch.ones(batch_shape),
                      constraint=constraints.interval(-1, 1),
                  )
              )
  
          skewness = torch.stack(skews, dim=-1)
          with pyro.plate("data", data.size(-len(data.size()))):
              pyro.sample(
                  "obs", SineSkewed(base_dist, skewness), obs=data
              )
  
      def guide(data, batch_shape):
          pass
  
      pyro.clear_param_store()
      adam = Adam({"lr": 0.1})
      svi = SVI(model, guide, adam, loss=Trace_ELBO())
  
      losses = []
      steps = 80
      for step in range(steps):
          losses.append(svi.step(data, base_dist.batch_shape))
  
      act_skewness = torch.stack(
          [v for k, v in pyro.get_param_store().items() if "skew" in k],
          dim=-1,
      )
      assert_equal(act_skewness, skewness_tar, 1e-1)
  
file_path: pyro/tests/distributions/test_sine_skewed.py
imports: from math import pi
  import pytest
  import torch
  import pyro
  from pyro.distributions import Normal, SineSkewed, Uniform, VonMises, constraints
  from pyro.infer import SVI, Trace_ELBO
  from pyro.optim import Adam
  from tests.common import assert_equal
label_desc: Use image node_id 3 for calling a global function with example usage: test_ss_mle(dim, dist) without return types