code: def test_posterior_predictive_svi_one_hot():
      pseudocounts = torch.ones(3) * 0.1
      true_probs = torch.tensor([0.15, 0.6, 0.25])
      classes = dist.OneHotCategorical(true_probs).sample((10000,))
      guide = AutoDelta(one_hot_model)
      svi = SVI(
          one_hot_model, guide, optim.Adam(dict(lr=0.1)), Trace_ELBO()
      )
      for i in range(1000):
          svi.step(pseudocounts, classes=classes)
      posterior_samples = Predictive(
          guide, num_samples=10000
      ).get_samples(pseudocounts)
      posterior_predictive = Predictive(
          one_hot_model, posterior_samples
      )
      marginal_return_vals = posterior_predictive.get_samples(
          pseudocounts
      )["obs"]
      assert_close(
          marginal_return_vals.mean(dim=0),
          true_probs.unsqueeze(0),
          rtol=0.1,
      )
  
file_path: pyro/tests/infer/test_predictive.py
imports: import pytest
  import torch
  import pyro
  import pyro.distributions
  import pyro.optim
  import pyro.poutine
  from pyro.infer import SVI, Predictive, Trace_ELBO
  from pyro.infer.autoguide import AutoDelta, AutoDiagonalNormal
  from tests.common import assert_close
label_desc: Use image node_id 7 for calling a global function with example usage: test_posterior_predictive_svi_one_hot() without return types