docstr: The base class for forecasting model explainers. It defines the *minimal* behavior that all
  forecasting model explainers support.
  
  Naming:
  
  - A background series is a `TimeSeries` with which to 'train' the `Explainer` model.
  - A foreground series is the `TimeSeries` to explain using the fitted `Explainer` model.
  
  Parameters
  ----------
  model
      A `ForecastingModel` to be explained. It must be fitted first.
  background_series
      A series or list of series to *train* the `_ForecastingModelExplainer` along with any foreground series.
      Consider using a reduced well-chosen background to reduce computation time.
      Optional if `model` was fit on a single target series. By default, it is the `series` used at fitting time.
      Mandatory if `model` was fit on multiple (sequence of) target series.
  background_past_covariates
      A past covariates series or list of series that the model needs once fitted.
  background_future_covariates
      A future covariates series or list of series that the model needs once fitted.
  requires_background
      Whether the explainer requires background series as an input. If `True`, raises an error if no background
      series were provided and `model` was fit using multiple series.
  requires_covariates_encoding
      Whether to apply the model's encoders to the input covariates. This should only be `True` if the
      Explainer will not call model methods `fit()` or `predict()` directly.
  check_component_names
      Whether to enforce that, in the case of multiple time series, all series of the same type (target and/or
      *_covariates) must have the same component names.
  test_stationarity
      Whether to raise a warning if not all `background_series` are stationary.
docstr_tok: ["The","base","class","for","forecasting","model","explainers",".","It","defines","the","*","minimal","*","behavior","that","all","forecasting","model","explainers","support",".","Naming",":","-","A","background","series","is","a","`","TimeSeries","`","with","which","to","'train","'","the","`","Explainer","`","model",".","-","A","foreground","series","is","the","`","TimeSeries","`","to","explain","using","the","fitted","`","Explainer","`","model",".","Parameters","--","--","--","--","--","model","A","`","ForecastingModel","`","to","be","explained",".","It","must","be","fitted","first",".","background_series","A","series","or","list","of","series","to","*","train","*","the","`","_ForecastingModelExplainer","`","along","with","any","foreground","series",".","Consider","using","a","reduced","well-chosen","background","to","reduce","computation","time",".","Optional","if","`","model","`","was","fit","on","a","single","target","series",".","By","default",",","it","is","the","`","series","`","used","at","fitting","time",".","Mandatory","if","`","model","`","was","fit","on","multiple","(","sequence","of",")","target","series",".","background_past_covariates","A","past","covariates","series","or","list","of","series","that","the","model","needs","once","fitted",".","background_future_covariates","A","future","covariates","series","or","list","of","series","that","the","model","needs","once","fitted",".","requires_background","Whether","the","explainer","requires","background","series","as","an","input",".","If","`","True","`",",","raises","an","error","if","no","background","series","were","provided","and","`","model","`","was","fit","using","multiple","series",".","requires_covariates_encoding","Whether","to","apply","the","model","'s","encoders","to","the","input","covariates",".","This","should","only","be","`","True","`","if","the","Explainer","will","not","call","model","methods","`","fit","(",")","`","or","`","predict","(",")","`","directly",".","check_component_names","Whether","to","enforce","that",",","in","the","case","of","multiple","time","series",",","all","series","of","the","same","type","(","target","and\/or","*","_covariates",")","must","have","the","same","component","names",".","test_stationarity","Whether","to","raise","a","warning","if","not","all","`","background_series","`","are","stationary","."]
code: def __init__(
      self,
      model: ForecastingModel,
      background_series: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      background_past_covariates: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      background_future_covariates: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      requires_background: bool = False,
      requires_covariates_encoding: bool = False,
      check_component_names: bool = False,
      test_stationarity: bool = False,
  ):
      """
      The base class for forecasting model explainers. It defines the *minimal* behavior that all
      forecasting model explainers support.
  
      Naming:
  
      - A background series is a `TimeSeries` with which to 'train' the `Explainer` model.
      - A foreground series is the `TimeSeries` to explain using the fitted `Explainer` model.
  
      Parameters
      ----------
      model
          A `ForecastingModel` to be explained. It must be fitted first.
      background_series
          A series or list of series to *train* the `_ForecastingModelExplainer` along with any foreground series.
          Consider using a reduced well-chosen background to reduce computation time.
          Optional if `model` was fit on a single target series. By default, it is the `series` used at fitting time.
          Mandatory if `model` was fit on multiple (sequence of) target series.
      background_past_covariates
          A past covariates series or list of series that the model needs once fitted.
      background_future_covariates
          A future covariates series or list of series that the model needs once fitted.
      requires_background
          Whether the explainer requires background series as an input. If `True`, raises an error if no background
          series were provided and `model` was fit using multiple series.
      requires_covariates_encoding
          Whether to apply the model's encoders to the input covariates. This should only be `True` if the
          Explainer will not call model methods `fit()` or `predict()` directly.
      check_component_names
          Whether to enforce that, in the case of multiple time series, all series of the same type (target and/or
          *_covariates) must have the same component names.
      test_stationarity
          Whether to raise a warning if not all `background_series` are stationary.
      """
      if not model._fit_called:
          raise_log(
              ValueError(
                  f"The model must be fitted before instantiating a {self.__class__.__name__}."
              ),
              logger,
          )
      self.model = model
      # default forecasting horizon
      self.n: Optional[int] = getattr(
          self.model, "output_chunk_length", None
      )
  
      # check background input validity and process it
      (
          self.background_series,
          self.background_past_covariates,
          self.background_future_covariates,
          self.target_components,
          self.static_covariates_components,
          self.past_covariates_components,
          self.future_covariates_components,
      ) = process_input(
          model=model,
          input_type="background",
          series=background_series,
          past_covariates=background_past_covariates,
          future_covariates=background_future_covariates,
          fallback_series=model.training_series,
          fallback_past_covariates=model.past_covariate_series,
          fallback_future_covariates=model.future_covariate_series,
          check_component_names=check_component_names,
          requires_input=requires_background,
          requires_covariates_encoding=requires_covariates_encoding,
          test_stationarity=test_stationarity,
      )
      self.requires_foreground = self.background_series is None
      self.requires_covariates_encoding = requires_covariates_encoding
      self.check_component_names = check_component_names
      self.test_stationarity = test_stationarity
  
file_path: darts/darts/explainability/explainability.py
imports: from abc import ABC, abstractmethod
  from typing import Optional, Sequence, Tuple, Union
  from darts import TimeSeries
  from darts.explainability.explainability_result import _ExplainabilityResult
  from darts.explainability.utils import process_horizons_and_targets, process_input
  from darts.logging import get_logger, raise_log
  from darts.models.forecasting.forecasting_model import ForecastingModel
label_desc: Use image node_id 1 to create a new _ForecastingModelExplainer object from inherited base classes: ABC with example: obj = _ForecastingModelExplainer(model, background_series, background_past_covariates, background_future_covariates, requires_background, requires_covariates_encoding, check_component_names, test_stationarity)