def test_historical_forecasts_start_too_early(self, caplog, config):
        """If start is not within the trainable/forecastable index, it should start a round-multiple of `stride` ahead
        of `start`. Checks for:
        - correct warnings
        - datetime / integer index
        - different frequencies
        - different strides
        - start "value" and "position"
        - retrain / no-retrain (optimized and non-optimized)
        - torch and regression model
        """
        # the configuration is defined for `retrain = True` and `start_format = "value"`
        (
            (start, stride, start_expected, freq),
            start_format,
            retrain,
            use_torch_model,
        ) = config
        if isinstance(freq, str):
            start, start_expected = pd.Timestamp(start), pd.Timestamp(start_expected)
            start_series = pd.Timestamp("2000-01-01 00:00:00")
        else:
            start_series = 0

        series = tg.linear_timeseries(
            start=start_series,
            length=7,
            freq=freq,
        )
        # when hist fc `start` is not in the valid frequency range, it is converted to a time that is valid.
        # e.g. `start="1999-12-31 23:00:00:` with `freq="2h"` is converted to `"2000-01-01 00:00:00"`
        start_position = n_steps_between(end=start_series, start=start, freq=freq)
        start_time_expected = series.start_time() - start_position * series.freq

        if start_format == "position":
            start = -start_position
            if start < 0:
                # negative position is relative to the end of the series
                start -= len(series)
            start_format_msg = f"position `{start}` corresponding to time "
        else:
            start_format_msg = "time "

        if use_torch_model:
            kwargs = deepcopy(tfm_kwargs)
            kwargs["pl_trainer_kwargs"]["fast_dev_run"] = True
            # use ocl=2 to have same `min_train_length` as the regression model
            model = BlockRNNModel(
                input_chunk_length=1, output_chunk_length=2, n_epochs=1, **kwargs
            )
        else:
            model = LinearRegressionModel(lags=1)

        model.fit(series)
        # if the stride is shorter than the train series length, retrain=False can start earlier
        if not retrain and stride <= model.min_train_series_length:
            start_expected -= (
                model.min_train_series_length + model.extreme_lags[0]
            ) * series.freq

        # label index
        warning_expected = (
            f"`start` {start_format_msg}`{start_time_expected}` is before the first predictable/trainable historical "
            f"forecasting point for series at index: 0. Using the first historical forecasting point "
            f"`{start_expected}` that lies a round-multiple of `stride={stride}` ahead of `start`. To hide these "
            f"warnings, set `show_warnings=False`."
        )

        # check that warning is raised when too early
        enable_optimizations = [False] if retrain else [False, True]
        for enable_optimization in enable_optimizations:
            with caplog.at_level(logging.WARNING):
                pred = model.historical_forecasts(
                    series,
                    start=start,
                    stride=stride,
                    retrain=retrain,
                    start_format=start_format,
                    enable_optimization=enable_optimization,
                )
                assert warning_expected in caplog.text
                assert pred.start_time() == start_expected
        caplog.clear()
        # but no warning when start is at the right time
        warning_short = (
            f"Using the first historical forecasting point `{start_expected}` that lies a round-multiple "
            f"of `stride={stride}` ahead of `start`. To hide these warnings, set `show_warnings=False`."
        )
        with caplog.at_level(logging.WARNING):
            pred = model.historical_forecasts(
                series,
                start=start_expected,
                stride=stride,
                retrain=False,
                start_format="value",
                enable_optimization=True,
            )
            assert warning_short not in caplog.text
            assert pred.start_time() == start_expected
If start is not within the trainable/forecastable index, it should start a round-multiple of `stride` ahead
        of `start`. Checks for:
        - correct warnings
        - datetime / integer index
        - different frequencies
        - different strides
        - start "value" and "position"
        - retrain / no-retrain (optimized and non-optimized)
        - torch and regression model
        
darts/tests/utils/historical_forecasts/test_historical_forecasts.py