code: def test_given_hyperparameter_spaces_when_tune_called_then_tuning_output_correct(
      model_class, temp_model_path
  ):
      model = model_class(
          path=temp_model_path,
          freq="H",
          quantile_levels=[0.1, 0.9],
          hyperparameters={
              "epochs": space.Int(1, 3),
              "num_batches_per_epoch": 1,
              "use_fallback_model": False,
          },
      )
      if isinstance(model, MultiWindowBacktestingModel):
          val_data = None
      else:
          val_data = DUMMY_TS_DATAFRAME
  
      num_trials = 2
  
      hpo_results, _ = model.hyperparameter_tune(
          hyperparameter_tune_kwargs={
              "num_trials": num_trials,
              "scheduler": "local",
              "searcher": "random",
          },
          time_limit=300,
          train_data=DUMMY_TS_DATAFRAME,
          val_data=val_data,
      )
      assert len(hpo_results) == num_trials
      for result in hpo_results.values():
          assert 1 <= result["hyperparameters"]["epochs"] <= 3
  
imports: import itertools
  import shutil
  import sys
  import tempfile
  from unittest import mock
  import numpy
  import pandas
  import pytest
  from flaky import flaky
  from autogluon.common import space
  from autogluon.core.hpo.constants import RAY_BACKEND
  from autogluon.timeseries import TimeSeriesDataFrame
  from autogluon.timeseries.dataset.ts_dataframe import ITEMID, TIMESTAMP
  from autogluon.timeseries.metrics import AVAILABLE_METRICS
  from autogluon.timeseries.models import DeepARModel, ETSModel
  from autogluon.timeseries.models.abstract import AbstractTimeSeriesModel
  from autogluon.timeseries.models.multi_window import MultiWindowBacktestingModel
  from ..common import DUMMY_TS_DATAFRAME, CustomMetric, dict_equal_primitive, get_data_frame_with_item_index
  from .test_gluonts import TESTABLE_MODELS
  from .test_local import TESTABLE_MODELS
  from .test_mlforecast import TESTABLE_MODELS
  from .test_multi_window_model import get_multi_window_deepar
label_desc: Use image node_id 8 for calling a global function with example usage: test_given_hyperparameter_spaces_when_tune_called_then_tuning_output_correct(model_class, temp_model_path) without return types