code: def test_sparse_smoke(duration, forecast, options):
      population = 100
      recovery_time = 7.0
  
      # Generate data.
      data = [None] * duration
      mask = torch.arange(duration) % 4 == 3
      model = SparseSIRModel(population, recovery_time, data, mask)
      assert model.full_mass == [("R0", "rho")]
      for attempt in range(100):
          data = model.generate({"R0": 1.5, "rho": 0.5})["obs"]
          if data.sum():
              break
      assert data.sum() > 0, "failed to generate positive data"
      assert (data[1:] >= data[:-1]).all()
      data[~mask] = math.nan
      logger.info("data:\n{}".format(data))
  
      # Infer.
      model = SparseSIRModel(population, recovery_time, data, mask)
      num_samples = 5
      model.fit_mcmc(
          warmup_steps=1,
          num_samples=num_samples,
          max_tree_depth=2,
          **options,
      )
  
      # Predict and forecast.
      samples = model.predict(forecast=forecast)
      assert samples["S"].shape == (num_samples, duration + forecast)
      assert samples["I"].shape == (num_samples, duration + forecast)
      assert samples["O"].shape == (num_samples, duration + forecast)
      assert (samples["O"][..., 1:] >= samples["O"][..., :-1]).all()
      for O in samples["O"]:
          logger.info("imputed:\n{}".format(O))
          assert (O[:duration][mask] == data[mask]).all()
  
imports: import logging
  import math
  import pytest
  import torch
  import pyro
  import pyro.distributions
  from pyro.contrib.epidemiology.models import HeterogeneousRegionalSIRModel, HeterogeneousSIRModel, OverdispersedSEIRModel, OverdispersedSIRModel, RegionalSIRModel, SimpleSEIRDModel, SimpleSEIRModel, SimpleSIRModel, SparseSIRModel, SuperspreadingSEIRModel, SuperspreadingSIRModel, UnknownStartSIRModel
  from tests.common import xfail_param
label_desc: Use image node_id 10 for calling a global function with example usage: test_sparse_smoke(duration, forecast, options) without return types