docstr: Compute the historical forecasts that would have been obtained by this model on the `series`.
  
  `retrain` is set to False if possible (this is not supported by all models). If set to True, it will always
  re-train the model on the entire available history,
  
  Parameters
  ----------
  series
      The target time series to use to successively train and evaluate the historical forecasts.
  past_covariates
      An optional past-observed covariate series or sequence of series. This applies only if the model
      supports past covariates.
  future_covariates
      An optional future-known covariate series or sequence of series. This applies only if the model
      supports future covariates.
  forecast_horizon
      The forecast horizon for the predictions
  start
      The first point of time at which a prediction is computed for a future time.
      This parameter supports 3 different data types: ``float``, ``int`` and ``pandas.Timestamp``.
      In the case of ``float``, the parameter will be treated as the proportion of the time series
      that should lie before the first prediction point.
      In the case of ``int``, the parameter will be treated as an integer index to the time index of
      `series` that will be used as first prediction time.
      In case of ``pandas.Timestamp``, this time stamp will be used to determine the first prediction time
      directly.
  num_samples
      Number of times a prediction is sampled from a probabilistic model. Should be left set to 1 for
      deterministic models.
  
  Returns
  -------
  TimeSeries
      Single ``TimeSeries`` instance created from the last point of each individual forecast.
docstr_tok: ["Compute","the","historical","forecasts","that","would","have","been","obtained","by","this","model","on","the","`","series","`",".","`","retrain","`","is","set","to","False","if","possible","(","this","is","not","supported","by","all","models",")",".","If","set","to","True",",","it","will","always","re-train","the","model","on","the","entire","available","history",",","Parameters","--","--","--","--","--","series","The","target","time","series","to","use","to","successively","train","and","evaluate","the","historical","forecasts",".","past_covariates","An","optional","past-observed","covariate","series","or","sequence","of","series",".","This","applies","only","if","the","model","supports","past","covariates",".","future_covariates","An","optional","future-known","covariate","series","or","sequence","of","series",".","This","applies","only","if","the","model","supports","future","covariates",".","forecast_horizon","The","forecast","horizon","for","the","predictions","start","The","first","point","of","time","at","which","a","prediction","is","computed","for","a","future","time",".","This","parameter","supports","3","different","data","types",":","``","float","``",",","``","int","``","and","``","pandas.Timestamp","``",".","In","the","case","of","``","float","``",",","the","parameter","will","be","treated","as","the","proportion","of","the","time","series","that","should","lie","before","the","first","prediction","point",".","In","the","case","of","``","int","``",",","the","parameter","will","be","treated","as","an","integer","index","to","the","time","index","of","`","series","`","that","will","be","used","as","first","prediction","time",".","In","case","of","``","pandas.Timestamp","``",",","this","time","stamp","will","be","used","to","determine","the","first","prediction","time","directly",".","num_samples","Number","of","times","a","prediction","is","sampled","from","a","probabilistic","model",".","Should","be","left","set","to","1","for","deterministic","models",".","Returns","--","--","--","-","TimeSeries","Single","``","TimeSeries","``","instance","created","from","the","last","point","of","each","individual","forecast","."]
code: def _predict_with_forecasting(
      self,
      series: TimeSeries,
      past_covariates: Optional[TimeSeries] = None,
      future_covariates: Optional[TimeSeries] = None,
      forecast_horizon: int = 1,
      start: Union[pd.Timestamp, float, int] = None,
      num_samples: int = 1,
  ) -> TimeSeries:
      """Compute the historical forecasts that would have been obtained by this model on the `series`.
  
      `retrain` is set to False if possible (this is not supported by all models). If set to True, it will always
      re-train the model on the entire available history,
  
      Parameters
      ----------
      series
          The target time series to use to successively train and evaluate the historical forecasts.
      past_covariates
          An optional past-observed covariate series or sequence of series. This applies only if the model
          supports past covariates.
      future_covariates
          An optional future-known covariate series or sequence of series. This applies only if the model
          supports future covariates.
      forecast_horizon
          The forecast horizon for the predictions
      start
          The first point of time at which a prediction is computed for a future time.
          This parameter supports 3 different data types: ``float``, ``int`` and ``pandas.Timestamp``.
          In the case of ``float``, the parameter will be treated as the proportion of the time series
          that should lie before the first prediction point.
          In the case of ``int``, the parameter will be treated as an integer index to the time index of
          `series` that will be used as first prediction time.
          In case of ``pandas.Timestamp``, this time stamp will be used to determine the first prediction time
          directly.
      num_samples
          Number of times a prediction is sampled from a probabilistic model. Should be left set to 1 for
          deterministic models.
  
      Returns
      -------
      TimeSeries
          Single ``TimeSeries`` instance created from the last point of each individual forecast.
      """
  
      # TODO: raise an exception. We only support models that do not need retrain
      # checks if model accepts to not be retrained in the historical_forecasts()
      if self.model._supports_non_retrainable_historical_forecasts:
          # default: set to False. Allows a faster computation.
          retrain = False
      else:
          retrain = True
  
      historical_forecasts_param = {
          "past_covariates": past_covariates,
          "future_covariates": future_covariates,
          "forecast_horizon": forecast_horizon,
          "start": start,
          "retrain": retrain,
          "num_samples": num_samples,
          "stride": 1,
          "last_points_only": True,
          "verbose": False,
      }
  
      return self.model.historical_forecasts(
          series, **historical_forecasts_param
      )
  
file_path: darts/darts/ad/anomaly_model/forecasting_am.py
imports: import inspect
  from typing import Dict, Optional, Sequence, Union
  import pandas
  from darts.ad.anomaly_model.anomaly_model import AnomalyModel
  from darts.ad.scorers.scorers import AnomalyScorer
  from darts.ad.utils import _assert_same_length, _assert_timeseries, _to_list
  from darts.logging import get_logger, raise_if_not
  from darts.models.forecasting.forecasting_model import ForecastingModel
  from darts.timeseries import TimeSeries
label_desc: Use image node_id 7 for calling the ForecastingAnomalyModel obj's underlying member method code with example usage: obj._predict_with_forecasting(series, past_covariates, future_covariates, forecast_horizon, start, num_samples) and returns: self