docstr: Explainer class for the `TFTModel`.
  
  **Definitions**
  
  - A background series is a `TimeSeries` that is used as a default for generating the explainability result
    (if no `foreground` is passed to :func:`explain() <TFTExplainer.explain>`).
  - A foreground series is a `TimeSeries` that can be passed to :func:`explain() <TFTExplainer.explain>` to use
    instead of the background for generating the explainability result.
  
  Parameters
  ----------
  model
      The fitted `TFTModel` to be explained.
  background_series
      Optionally, a series or list of series to use as a default target series for the explanations.
      Optional if `model` was trained on a single target series. By default, it is the `series` used at fitting
      time.
      Mandatory if `model` was trained on multiple (sequence of) target series.
  background_past_covariates
      Optionally, a past covariates series or list of series to use as a default past covariates series
      for the explanations. The same requirements apply as for `background_series` .
  background_future_covariates
      Optionally, a future covariates series or list of series to use as a default future covariates series
      for the explanations. The same requirements apply as for `background_series`.
  
  Examples
  --------
  >>> from darts.datasets import AirPassengersDataset
  >>> from darts.explainability.tft_explainer import TFTExplainer
  >>> from darts.models import TFTModel
  >>> series = AirPassengersDataset().load()
  >>> model = TFTModel(
  >>>     input_chunk_length=12,
  >>>     output_chunk_length=6,
  >>>     add_encoders={"cyclic": {"future": ["hour"]}}
  >>> )
  >>> model.fit(series)
  >>> # create the explainer and generate explanations
  >>> explainer = TFTExplainer(model)
  >>> results = explainer.explain()
  >>> # plot the results
  >>> explainer.plot_attention(results, plot_type="all")
  >>> explainer.plot_variable_selection(results)
docstr_tok: ["Explainer","class","for","the","`","TFTModel","`",".","*","*","Definitions","*","*","-","A","background","series","is","a","`","TimeSeries","`","that","is","used","as","a","default","for","generating","the","explainability","result","(","if","no","`","foreground","`","is","passed","to",":","func",":","`","explain","(",")","<","TFTExplainer.explain",">","`",")",".","-","A","foreground","series","is","a","`","TimeSeries","`","that","can","be","passed","to",":","func",":","`","explain","(",")","<","TFTExplainer.explain",">","`","to","use","instead","of","the","background","for","generating","the","explainability","result",".","Parameters","--","--","--","--","--","model","The","fitted","`","TFTModel","`","to","be","explained",".","background_series","Optionally",",","a","series","or","list","of","series","to","use","as","a","default","target","series","for","the","explanations",".","Optional","if","`","model","`","was","trained","on","a","single","target","series",".","By","default",",","it","is","the","`","series","`","used","at","fitting","time",".","Mandatory","if","`","model","`","was","trained","on","multiple","(","sequence","of",")","target","series",".","background_past_covariates","Optionally",",","a","past","covariates","series","or","list","of","series","to","use","as","a","default","past","covariates","series","for","the","explanations",".","The","same","requirements","apply","as","for","`","background_series","`",".","background_future_covariates","Optionally",",","a","future","covariates","series","or","list","of","series","to","use","as","a","default","future","covariates","series","for","the","explanations",".","The","same","requirements","apply","as","for","`","background_series","`",".","Examples","--","--","--","--",">",">",">","from","darts.datasets","import","AirPassengersDataset",">",">",">","from","darts.explainability.tft_explainer","import","TFTExplainer",">",">",">","from","darts.models","import","TFTModel",">",">",">","series","=","AirPassengersDataset","(",")",".load","(",")",">",">",">","model","=","TFTModel","(",">",">",">","input_chunk_length=12",",",">",">",">","output_chunk_length=6",",",">",">",">","add_encoders=","{","``","cyclic","''",":","{","``","future","''",":","[","``","hour","''","]","}","}",">",">",">",")",">",">",">","model.fit","(","series",")",">",">",">","#","create","the","explainer","and","generate","explanations",">",">",">","explainer","=","TFTExplainer","(","model",")",">",">",">","results","=","explainer.explain","(",")",">",">",">","#","plot","the","results",">",">",">","explainer.plot_attention","(","results",",","plot_type=","''","all","''",")",">",">",">","explainer.plot_variable_selection","(","results",")"]
code: def __init__(
      self,
      model: TFTModel,
      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,
  ):
      """
      Explainer class for the `TFTModel`.
  
      **Definitions**
  
      - A background series is a `TimeSeries` that is used as a default for generating the explainability result
        (if no `foreground` is passed to :func:`explain() <TFTExplainer.explain>`).
      - A foreground series is a `TimeSeries` that can be passed to :func:`explain() <TFTExplainer.explain>` to use
        instead of the background for generating the explainability result.
  
      Parameters
      ----------
      model
          The fitted `TFTModel` to be explained.
      background_series
          Optionally, a series or list of series to use as a default target series for the explanations.
          Optional if `model` was trained on a single target series. By default, it is the `series` used at fitting
          time.
          Mandatory if `model` was trained on multiple (sequence of) target series.
      background_past_covariates
          Optionally, a past covariates series or list of series to use as a default past covariates series
          for the explanations. The same requirements apply as for `background_series` .
      background_future_covariates
          Optionally, a future covariates series or list of series to use as a default future covariates series
          for the explanations. The same requirements apply as for `background_series`.
  
      Examples
      --------
      >>> from darts.datasets import AirPassengersDataset
      >>> from darts.explainability.tft_explainer import TFTExplainer
      >>> from darts.models import TFTModel
      >>> series = AirPassengersDataset().load()
      >>> model = TFTModel(
      >>>     input_chunk_length=12,
      >>>     output_chunk_length=6,
      >>>     add_encoders={"cyclic": {"future": ["hour"]}}
      >>> )
      >>> model.fit(series)
      >>> # create the explainer and generate explanations
      >>> explainer = TFTExplainer(model)
      >>> results = explainer.explain()
      >>> # plot the results
      >>> explainer.plot_attention(results, plot_type="all")
      >>> explainer.plot_variable_selection(results)
      """
      super().__init__(
          model,
          background_series=background_series,
          background_past_covariates=background_past_covariates,
          background_future_covariates=background_future_covariates,
          requires_background=True,
          requires_covariates_encoding=False,
          check_component_names=False,
          test_stationarity=False,
      )
      # add the relative index that generated inside the model (not in the input data)
      if model.add_relative_index:
          if self.future_covariates_components is not None:
              self.future_covariates_components.append(
                  "add_relative_index"
              )
          else:
              self.future_covariates_components = ["add_relative_index"]
  
imports: from typing import Dict, List, Optional, Sequence, Union
  import matplotlib.axes
  import matplotlib.pyplot
  import numpy
  import pandas
  from torch import Tensor
  from darts import TimeSeries
  from darts.explainability import TFTExplainabilityResult
  from darts.explainability.explainability import _ForecastingModelExplainer
  from darts.logging import get_logger, raise_log
  from darts.models import TFTModel
  from darts.utils.timeseries_generation import generate_index
label_desc: Use image node_id 1 to create a new TFTExplainer object from inherited base classes: _ForecastingModelExplainer with example: obj = TFTExplainer(model, background_series, background_past_covariates, background_future_covariates)