code: def _historical_forecasts_general_checks(model, series, kwargs):
      """
      Performs checks common to ForecastingModel and RegressionModel backtest() methods
  
      Parameters
      ----------
      model
          The forecasting model.
      series
          Either series when called from ForecastingModel, or target_series if called from RegressionModel
      signature_params
          A dictionary of the signature parameters of the calling method, to get the default values
          Typically would be signature(self.backtest).parameters
      kwargs
          Params specified by the caller of backtest(), they take precedence over the arguments' default values
      """
      # parse kwargs
      n = SimpleNamespace(**kwargs)
  
      # check forecast horizon
      raise_if_not(
          n.forecast_horizon > 0,
          "The provided forecasting horizon must be a positive integer.",
          logger,
      )
  
      # check stride
      raise_if_not(
          n.stride > 0,
          "The provided stride parameter must be a positive integer.",
          logger,
      )
  
      series = series2seq(series)
  
      if n.start is not None:
          # check start parameter in general (non series dependent)
          if not isinstance(
              n.start, (float, int, np.int64, pd.Timestamp)
          ):
              raise_log(
                  TypeError(
                      "`start` must be either `float`, `int`, `pd.Timestamp` or `None`."
                  ),
                  logger,
              )
  
          if n.start_format not in ["position", "value"]:
              raise_log(
                  ValueError(
                      f"`start_format` must be on of ['position', 'value']. Received '{n.start_format}'."
                  )
              )
          if n.start_format == "position":
              raise_if_not(
                  isinstance(n.start, (int, np.int64)),
                  f"Since `start_format='position'`, `start` must be an integer, received {type(n.start)}.",
                  logger,
              )
  
          if isinstance(n.start, float):
              raise_if_not(
                  0.0 <= n.start <= 1.0,
                  "if `start` is a float, must be between 0.0 and 1.0.",
                  logger,
              )
  
          # verbose error messages
          if not isinstance(n.start, pd.Timestamp):
              start_value_msg = f"`start` value `{n.start}` corresponding to timestamp"
          else:
              start_value_msg = "`start` time"
          for idx, series_ in enumerate(series):
              # check specifically for int and Timestamp as error by `get_timestamp_at_point` is too generic
              if isinstance(n.start, pd.Timestamp):
                  if n.start > series_.end_time():
                      raise_log(
                          ValueError(
                              f"`start` time `{n.start}` is after the last timestamp `{series_.end_time()}` of the "
                              f"series at index: {idx}."
                          ),
                          logger,
                      )
                  elif n.start < series_.start_time():
                      raise_log(
                          ValueError(
                              f"`start` time `{n.start}` is before the first timestamp `{series_.start_time()}` of the "
                              f"series at index: {idx}."
                          ),
                          logger,
                      )
              elif isinstance(n.start, (int, np.int64)):
                  out_of_bound_error = False
                  if n.start_format == "position":
                      if (n.start > 0 and n.start >= len(series_)) or (
                          n.start < 0 and np.abs(n.start) > len(series_)
                      ):
                          out_of_bound_error = True
                  elif series_.has_datetime_index:
                      if n.start >= len(series_):
                          out_of_bound_error = True
                  elif n.start < series_.time_index[0]:
                      raise_log(
                          ValueError(
                              f"`start` index `{n.start}` is smaller than the first index `{series_.time_index[0]}` "
                              f"for series at index: {idx}."
                          ),
                          logger,
                      )
                  elif n.start > series_.time_index[-1]:
                      raise_log(
                          ValueError(
                              f"`start` index `{n.start}` is larger than the last index `{series_.time_index[-1]}` "
                              f"for series at index: {idx}."
                          ),
                          logger,
                      )
  
                  if out_of_bound_error:
                      raise_log(
                          ValueError(
                              f"`start` index `{n.start}` is out of bounds for series of length {len(series_)} "
                              f"at index: {idx}."
                          ),
                          logger,
                      )
  
              if n.start_format == "value":
                  start = series_.get_timestamp_at_point(n.start)
              else:
                  start = series_.time_index[n.start]
  
              if (
                  n.retrain is not False
                  and start == series_.start_time()
              ):
                  raise_log(
                      ValueError(
                          f"{start_value_msg} `{start}` is the first timestamp of the series {idx}, resulting in an "
                          f"empty training set."
                      ),
                      logger,
                  )
  
              # check that overlap_end and start together form a valid combination
              overlap_end = n.overlap_end
              if not overlap_end and not (
                  start + (series_.freq * (n.forecast_horizon - 1))
                  in series_
              ):
                  raise_log(
                      ValueError(
                          f"{start_value_msg} `{start}` is too late in the series {idx} to make any predictions with "
                          f"`overlap_end` set to `False`."
                      ),
                      logger,
                  )
  
      # check direct likelihood parameter prediction before fitting a model
      if n.predict_likelihood_parameters:
          if not model.supports_likelihood_parameter_prediction:
              raise_log(
                  ValueError(
                      f"Model `{model.__class__.__name__}` does not support `predict_likelihood_parameters=True`. "
                      f"Either the model does not support likelihoods, or no `likelihood` was used at model "
                      f"creation."
                  )
              )
          if n.num_samples != 1:
              raise_log(
                  ValueError(
                      f"`predict_likelihood_parameters=True` is only supported for `num_samples=1`, "
                      f"received {n.num_samples}."
                  ),
                  logger,
              )
  
          if (
              model.output_chunk_length is not None
              and n.forecast_horizon > model.output_chunk_length
          ):
              raise_log(
                  ValueError(
                      "`predict_likelihood_parameters=True` is only supported for `forecast_horizon` smaller than or "
                      "equal to model's `output_chunk_length`."
                  ),
                  logger,
              )
  
imports: from types import SimpleNamespace
  from typing import Any, Callable, Dict, Optional, Sequence, Set, Tuple, Union
  import inspect
  import numpy
  import pandas
  from numpy.typing import ArrayLike
  from darts.logging import get_logger, raise_if_not, raise_log
  from darts.timeseries import TimeSeries
  from darts.utils.timeseries_generation import generate_index
  from darts.utils.utils import series2seq
label_desc: Use image node_id 1 for calling a global function with example usage: _historical_forecasts_general_checks(model, series, kwargs) without return types