def _fit_core(
        self,
        series: Sequence[TimeSeries],
        past_covariates: Optional[Sequence[TimeSeries]] = None,
        future_covariates: Optional[Sequence[TimeSeries]] = None,
        allow_model_training: bool = False,
        forecast_horizon: int = 1,
        start: Union[pd.Timestamp, float, int] = 0.5,
        start_format: Literal["position", "value"] = "value",
        num_samples: int = 1,
        verbose: bool = False,
        show_warnings: bool = True,
        enable_optimization: bool = True,
        **model_fit_kwargs,
    ):
        """Fit the forecasting model (if applicable) and scorers."""
        # fit forecasting model
        if allow_model_training:
            self.model._fit_wrapper(
                series=series,
                past_covariates=past_covariates,
                future_covariates=future_covariates,
                **model_fit_kwargs,
            )
        elif not self.model._fit_called:
            raise_log(
                ValueError(
                    f"With `allow_model_training=False`, the underlying model `{self.model.__class__.__name__}` "
                    f"must have already been trained. Either train it before or set `allow_model_training=True` "
                    f"(model will trained from scratch on the provided series)."
                ),
                logger=logger,
            )

        # generate the historical_forecast() prediction of the model on the train set
        if self.scorers_are_trainable:
            historical_forecasts = self.predict_series(
                series=series,
                past_covariates=past_covariates,
                future_covariates=future_covariates,
                forecast_horizon=forecast_horizon,
                start=start,
                start_format=start_format,
                num_samples=num_samples,
                verbose=verbose,
                show_warnings=show_warnings,
                enable_optimization=enable_optimization,
            )
            # fit the scorers
            self._fit_scorers(series, historical_forecasts)
Fit the forecasting model (if applicable) and scorers.
darts/ad/anomaly_model/forecasting_am.py