docstr: Compute anomaly score(s) for the given series.
  
  Predicts the given target time series with the forecasting model, and applies the scorer(s)
  on the prediction and the target input time series. Outputs the anomaly score of the given
  input time series.
  
  Parameters
  ----------
  series
      The (sequence of) series to score on.
  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. Default: 0.5
  num_samples
      Number of times a prediction is sampled from a probabilistic model. Should be left set to 1 for
      deterministic models.
  return_model_prediction
      Boolean value indicating if the prediction of the model should be returned along the anomaly score
      Default: False
  
  Returns
  -------
  Union[TimeSeries, Sequence[TimeSeries], Sequence[Sequence[TimeSeries]]]
      Anomaly scores series generated by the anomaly model scorers
  
          - ``TimeSeries`` if `series` is a series, and the anomaly model contains one scorer.
          - ``Sequence[TimeSeries]``
  
              * if `series` is a series, and the anomaly model contains multiple scorers,
                returns one series per scorer.
              * if `series` is a sequence, and the anomaly model contains one scorer,
                returns one series per series in the sequence.
          - ``Sequence[Sequence[TimeSeries]]`` if `series` is a sequence, and the anomaly
            model contains multiple scorers. The outer sequence is over the series,
            and inner sequence is over the scorers.
docstr_tok: ["Compute","anomaly","score","(","s",")","for","the","given","series",".","Predicts","the","given","target","time","series","with","the","forecasting","model",",","and","applies","the","scorer","(","s",")","on","the","prediction","and","the","target","input","time","series",".","Outputs","the","anomaly","score","of","the","given","input","time","series",".","Parameters","--","--","--","--","--","series","The","(","sequence","of",")","series","to","score","on",".","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",".","Default",":","0.5","num_samples","Number","of","times","a","prediction","is","sampled","from","a","probabilistic","model",".","Should","be","left","set","to","1","for","deterministic","models",".","return_model_prediction","Boolean","value","indicating","if","the","prediction","of","the","model","should","be","returned","along","the","anomaly","score","Default",":","False","Returns","--","--","--","-","Union","[","TimeSeries",",","Sequence","[","TimeSeries","]",",","Sequence","[","Sequence","[","TimeSeries","]","]","]","Anomaly","scores","series","generated","by","the","anomaly","model","scorers","-","``","TimeSeries","``","if","`","series","`","is","a","series",",","and","the","anomaly","model","contains","one","scorer",".","-","``","Sequence","[","TimeSeries","]","``","*","if","`","series","`","is","a","series",",","and","the","anomaly","model","contains","multiple","scorers",",","returns","one","series","per","scorer",".","*","if","`","series","`","is","a","sequence",",","and","the","anomaly","model","contains","one","scorer",",","returns","one","series","per","series","in","the","sequence",".","-","``","Sequence","[","Sequence","[","TimeSeries","]","]","``","if","`","series","`","is","a","sequence",",","and","the","anomaly","model","contains","multiple","scorers",".","The","outer","sequence","is","over","the","series",",","and","inner","sequence","is","over","the","scorers","."]
code: def score(
      self,
      series: Union[TimeSeries, Sequence[TimeSeries]],
      past_covariates: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      future_covariates: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      forecast_horizon: int = 1,
      start: Union[pd.Timestamp, float, int] = 0.5,
      num_samples: int = 1,
      return_model_prediction: bool = False,
  ) -> Union[TimeSeries, Sequence[TimeSeries]]:
      """Compute anomaly score(s) for the given series.
  
      Predicts the given target time series with the forecasting model, and applies the scorer(s)
      on the prediction and the target input time series. Outputs the anomaly score of the given
      input time series.
  
      Parameters
      ----------
      series
          The (sequence of) series to score on.
      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. Default: 0.5
      num_samples
          Number of times a prediction is sampled from a probabilistic model. Should be left set to 1 for
          deterministic models.
      return_model_prediction
          Boolean value indicating if the prediction of the model should be returned along the anomaly score
          Default: False
  
      Returns
      -------
      Union[TimeSeries, Sequence[TimeSeries], Sequence[Sequence[TimeSeries]]]
          Anomaly scores series generated by the anomaly model scorers
  
              - ``TimeSeries`` if `series` is a series, and the anomaly model contains one scorer.
              - ``Sequence[TimeSeries]``
  
                  * if `series` is a series, and the anomaly model contains multiple scorers,
                    returns one series per scorer.
                  * if `series` is a sequence, and the anomaly model contains one scorer,
                    returns one series per series in the sequence.
              - ``Sequence[Sequence[TimeSeries]]`` if `series` is a sequence, and the anomaly
                model contains multiple scorers. The outer sequence is over the series,
                and inner sequence is over the scorers.
      """
      raise_if_not(
          type(return_model_prediction) is bool,
          f"`return_model_prediction` must be Boolean, found type: {type(return_model_prediction)}.",
      )
  
      raise_if_not(
          self.model._fit_called,
          f"Model {self.model} has not been trained. Please call ``.fit()``.",
      )
  
      list_series = _to_list(series)
  
      list_past_covariates = self._prepare_covariates(
          past_covariates, list_series, "past"
      )
      list_future_covariates = self._prepare_covariates(
          future_covariates, list_series, "future"
      )
  
      # check if the window size of the scorers are lower than the max size allowed
      self._check_window_size(list_series, start)
  
      list_pred = []
      for idx, s in enumerate(list_series):
          if list_past_covariates is not None:
              past_covariates = list_past_covariates[idx]
  
          if list_future_covariates is not None:
              future_covariates = list_future_covariates[idx]
  
          list_pred.append(
              self._predict_with_forecasting(
                  s,
                  past_covariates=past_covariates,
                  future_covariates=future_covariates,
                  forecast_horizon=forecast_horizon,
                  start=start,
                  num_samples=num_samples,
              )
          )
  
      scores = list(
          zip(
              *[
                  sc.score_from_prediction(list_series, list_pred)
                  for sc in self.scorers
              ]
          )
      )
  
      if len(scores) == 1 and not isinstance(series, Sequence):
          # there's only one series
          scores = scores[0]
          if len(scores) == 1:
              # there's only one scorer
              scores = scores[0]
  
      if len(list_pred) == 1:
          list_pred = list_pred[0]
  
      if return_model_prediction:
          return scores, list_pred
      else:
          return scores
  
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 5 for calling the ForecastingAnomalyModel obj's underlying member method code with example usage: obj.score(series, past_covariates, future_covariates, forecast_horizon, start, num_samples, return_model_prediction) and returns: scores,  list_pred, scores