code: def test_tune_custom_grid_and_choose_better(load_pos_and_neg_data):
      """Tests
      (1) passing a custom grid to tune_model, and
      (2) choose_better=True
      """
  
      exp = TSForecastingExperiment()
  
      fh = np.arange(1, 13)
      fold = 2
      data = load_pos_and_neg_data
  
      exp.setup(
          data=data,
          fh=fh,
          fold=fold,
          fold_strategy="expanding",
          verbose=False,
          session_id=42,
      )
  
      model = exp.create_model("naive")
  
      # Custom Grid
      only_strategy = "mean"
      custom_grid = {"strategy": [only_strategy]}
  
      # By default choose_better = True
      tuned_model1 = exp.tune_model(model, custom_grid=custom_grid)
  
      # Choose Better = False
      tuned_model2 = exp.tune_model(
          model, custom_grid=custom_grid, choose_better=False
      )
  
      # Same strategy should be chosen since choose_better = True by default
      assert tuned_model1.strategy == model.strategy
      # should pick only value in custom grid
      assert tuned_model2.strategy == only_strategy
      # tuned model does improve score (verified manually), and choose_better
      # set to False. So pick worse value itself.
      assert tuned_model2.strategy != model.strategy
  
      assert not isinstance(tuned_model1, ForecastingPipeline)
      assert not isinstance(tuned_model2, ForecastingPipeline)
  
file_path: pycaret/tests/test_time_series_tune_base.py
imports: import numpy
  import pandas
  import pytest
  from sktime.forecasting.compose import ForecastingPipeline
  from time_series_test_utils import _ALL_METRICS
  from pycaret.time_series import TSForecastingExperiment
label_desc: Use image node_id 1 for calling a global function with example usage: test_tune_custom_grid_and_choose_better(load_pos_and_neg_data) without return types