code: def test_simple(
      train_window,
      min_train_window,
      test_window,
      min_test_window,
      stride,
      warm_start,
  ):
      duration = 30
      obs_dim = 2
      covariates = torch.zeros(duration, 0)
      data = torch.randn(duration, obs_dim) + 4
      forecaster_options = {"num_steps": 2, "warm_start": warm_start}
  
      expect_error = warm_start and train_window is not None
      with optional(pytest.raises(ValueError), expect_error):
          windows = backtest(
              data,
              covariates,
              Model,
              train_window=train_window,
              min_train_window=min_train_window,
              test_window=test_window,
              min_test_window=min_test_window,
              stride=stride,
              forecaster_options=forecaster_options,
          )
      if not expect_error:
          assert any(window["t0"] == 0 for window in windows)
          if stride == 1:
              assert any(window["t2"] == duration for window in windows)
          for window in windows:
              assert window["train_walltime"] >= 0
              assert window["test_walltime"] >= 0
              for name in DEFAULT_METRICS:
                  assert name in window
                  assert 0 < window[name] < math.inf
  
file_path: pyro/tests/contrib/forecast/test_evaluate.py
imports: import math
  import pytest
  import torch
  import pyro
  import pyro.distributions
  from pyro.contrib.forecast import Forecaster, ForecastingModel, HMCForecaster, backtest
  from pyro.contrib.forecast.evaluate import DEFAULT_METRICS
  from pyro.util import optional
label_desc: Use image node_id 1 for calling a global function with example usage: test_simple(train_window, min_train_window, test_window, min_test_window, stride, warm_start) without return types