docstr: Test backtest method with different retrain arguments
docstr_tok: ["Test","backtest","method","with","different","retrain","arguments"]
code: def test_backtest_retrain(self, patch_retrain_func, params):
      """
      Test backtest method with different retrain arguments
      """
      (
          model_cls,
          retrainable,
          multivariate,
          retrain,
          model_type,
          variate_args,
      ) = params
      if variate_args is not None:
          if variate_args == "lr_univ_args":
              model_args = {"lags": [-1, -2, -3]}
          else:  # "lr_multiv_args"
              model_args = {
                  "lags": [-1, -2, -3],
                  "lags_past_covariates": [-1, -2, -3],
              }
      else:
          model_args = dict()
      model = model_cls(**model_args)
  
      if str(retrain) == "patch_retrain_func":
          retrain = patch_retrain_func
  
      series = self.ts_pass_train
  
      if (
          not isinstance(retrain, (int, bool, Callable))
          or (isinstance(retrain, int) and retrain < 0)
          or (isinstance(retrain, (Callable)) and (not retrainable))
          or ((retrain != 1) and (not retrainable))
      ):
          with pytest.raises(ValueError):
              _ = model.historical_forecasts(series, retrain=retrain)
  
      else:
          if isinstance(retrain, Mock):
              # resets patch_retrain_func call_count to 0
              retrain.call_count = 0
              retrain.side_effect = [True, False] * (len(series) // 2)
  
          fit_method_to_patch = f"darts.models.forecasting.forecasting_model.{model_type}._fit_wrapper"
          predict_method_to_patch = f"darts.models.forecasting.forecasting_model.{model_type}._predict_wrapper"
  
          with patch(fit_method_to_patch) as patch_fit_method:
              with patch(
                  predict_method_to_patch, side_effect=series
              ) as patch_predict_method:
                  # Set _fit_called attribute to True, otherwise retrain function is never called
                  model._fit_called = True
  
                  # run backtest
                  _ = model.historical_forecasts(
                      series,
                      past_covariates=series if multivariate else None,
                      retrain=retrain,
                  )
  
                  assert patch_predict_method.call_count > 1
                  assert patch_fit_method.call_count > 1
  
                  if isinstance(retrain, Mock):
                      # check that patch_retrain_func has been called at each iteration
                      assert retrain.call_count > 1
  
imports: import copy
  import itertools
  import os
  import pathlib
  from typing import Callable
  from unittest.mock import Mock, patch
  import numpy
  import pandas
  import pytest
  from darts.datasets import AirPassengersDataset, IceCreamHeaterDataset
  from darts.logging import get_logger
  from darts.metrics import mape
  from darts.models import ARIMA, BATS, FFT, TBATS, VARIMA, AutoARIMA, Croston, ExponentialSmoothing, FourTheta, KalmanForecaster, LinearRegressionModel, NaiveDrift, NaiveMean, NaiveMovingAverage, NaiveSeasonal, NotImportedModule, Prophet, RandomForest, RegressionModel, StatsForecastAutoARIMA, StatsForecastAutoCES, StatsForecastAutoETS, StatsForecastAutoTheta, Theta
  from darts.models.forecasting.forecasting_model import LocalForecastingModel, TransferableFutureCovariatesLocalForecastingModel
  from darts.timeseries import TimeSeries
  from darts.utils import timeseries_generation
  from darts.utils.utils import ModelMode, SeasonalityMode, TrendMode
label_desc: Use image node_id 15 for calling the TestLocalForecastingModels obj's underlying member method code with example usage: obj.test_backtest_retrain(patch_retrain_func, params) without return types