code: def compare_best_against_random(
      model_class, params, series, stride=1
  ):
      # instantiate best model in expanding window mode
      np.random.seed(1)
      best_model_1, _, _ = model_class.gridsearch(
          params,
          series,
          forecast_horizon=10,
          stride=stride,
          metric=mape,
          start=series.time_index[-21],
      )
  
      # instantiate best model in split mode
      train, val = series.split_before(series.time_index[-10])
      best_model_2, _, _ = model_class.gridsearch(
          params, train, val_series=val, metric=mape
      )
  
      # instantiate model with random parameters from 'params'
      random.seed(1)
      random_param_choice = {}
      for key in params.keys():
          random_param_choice[key] = random.choice(params[key])
      random_model = model_class(**random_param_choice)
  
      # perform backtest forecasting on both models
      best_score_1 = best_model_1.backtest(
          series, start=series.time_index[-21], forecast_horizon=10
      )
      random_score_1 = random_model.backtest(
          series, start=series.time_index[-21], forecast_horizon=10
      )
  
      # perform train/val evaluation on both models
      best_model_2.fit(train)
      best_score_2 = mape(best_model_2.predict(len(val)), series)
      random_model = model_class(**random_param_choice)
      random_model.fit(train)
      random_score_2 = mape(random_model.predict(len(val)), series)
  
      # check whether best models are at least as good as random models
      expanding_window_ok = best_score_1 <= random_score_1
      split_ok = best_score_2 <= random_score_2
  
      return expanding_window_ok and split_ok
  
imports: import random
  from itertools import product
  import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.datasets import AirPassengersDataset, MonthlyMilkDataset
  from darts.logging import get_logger
  from darts.metrics import mape, r2_score
  from darts.models import ARIMA, FFT, ExponentialSmoothing, NaiveDrift, NaiveSeasonal, Theta
  from darts.tests.conftest import tfm_kwargs
  from darts.utils.timeseries_generation import gaussian_timeseries
  from darts.utils.timeseries_generation import linear_timeseries
  from darts.utils.timeseries_generation import random_walk_timeseries
  from darts.utils.timeseries_generation import sine_timeseries
label_desc: Use image node_id 2 for calling a global function with example usage: compare_best_against_random(model_class, params, series, stride) and returns: unknown