class_docstr: Helper Class to wrap the different cases encountered with shap different explainers, multivariates,
  horizon etc.
  Aim to provide shap values for any type of RegressionModel. Manage the MultioutputRegressor cases.
  For darts RegressionModel only.
docstr: Return a dictionary of dictionaries of shap.Explanation instances:
  - the first dimension corresponds to the n forecasts ahead we want to explain (Horizon).
  - the second dimension corresponds to each component of the target time series.
  Parameters
  ----------
  foreground_X
      the Dataframe of lags features specific of darts RegressionModel.
  horizons
      Optionally, a list of integers representing which points/steps in the future we want to explain,
      starting from the first prediction step at 1. Currently, only forecasting models are supported which
      provide an `output_chunk_length` parameter. `horizons` must not be larger than `output_chunk_length`.
  target_components
      Optionally, a list of strings with the target components we want to explain.
docstr_tok: ["Return","a","dictionary","of","dictionaries","of","shap.Explanation","instances",":","-","the","first","dimension","corresponds","to","the","n","forecasts","ahead","we","want","to","explain","(","Horizon",")",".","-","the","second","dimension","corresponds","to","each","component","of","the","target","time","series",".","Parameters","--","--","--","--","--","foreground_X","the","Dataframe","of","lags","features","specific","of","darts","RegressionModel",".","horizons","Optionally",",","a","list","of","integers","representing","which","points\/steps","in","the","future","we","want","to","explain",",","starting","from","the","first","prediction","step","at","1",".","Currently",",","only","forecasting","models","are","supported","which","provide","an","`","output_chunk_length","`","parameter",".","`","horizons","`","must","not","be","larger","than","`","output_chunk_length","`",".","target_components","Optionally",",","a","list","of","strings","with","the","target","components","we","want","to","explain","."]
code: def shap_explanations(
      self,
      foreground_X: pd.DataFrame,
      horizons: Optional[Sequence[int]] = None,
      target_components: Optional[Sequence[str]] = None,
  ) -> Dict[int, Dict[str, shap.Explanation]]:
      """
      Return a dictionary of dictionaries of shap.Explanation instances:
      - the first dimension corresponds to the n forecasts ahead we want to explain (Horizon).
      - the second dimension corresponds to each component of the target time series.
      Parameters
      ----------
      foreground_X
          the Dataframe of lags features specific of darts RegressionModel.
      horizons
          Optionally, a list of integers representing which points/steps in the future we want to explain,
          starting from the first prediction step at 1. Currently, only forecasting models are supported which
          provide an `output_chunk_length` parameter. `horizons` must not be larger than `output_chunk_length`.
      target_components
          Optionally, a list of strings with the target components we want to explain.
  
      """
  
      # create a unified dictionary between multiOutputRegressor estimators and
      # native multiOutput estimators
      shap_explanations = {}
      if self.is_multioutputregressor:
          for h in horizons:
              tmp_n = {}
              for t_idx, t in enumerate(self.target_components):
                  if t not in target_components:
                      continue
                  explainer = self.explainers[h - 1][t_idx](
                      foreground_X
                  )
                  explainer.base_values = explainer.base_values.ravel()
                  explainer.time_index = foreground_X.index
                  tmp_n[t] = explainer
              shap_explanations[h] = tmp_n
      else:
          # the native multioutput forces us to recompute all horizons and targets
          shap_explanation_tmp = self.explainers(foreground_X)
          for h in horizons:
              tmp_n = {}
              for t_idx, t in enumerate(target_components):
                  if t not in target_components:
                      continue
                  if not self.single_output:
                      tmp_t = shap.Explanation(
                          shap_explanation_tmp.values[
                              :, :, self.target_dim * (h - 1) + t_idx
                          ]
                      )
                      tmp_t.data = shap_explanation_tmp.data
                      tmp_t.base_values = (
                          shap_explanation_tmp.base_values[
                              :, self.target_dim * (h - 1) + t_idx
                          ].ravel()
                      )
                  else:
                      tmp_t = shap_explanation_tmp
                      tmp_t.base_values = (
                          shap_explanation_tmp.base_values.ravel()
                      )
  
                  tmp_t.feature_names = (
                      shap_explanation_tmp.feature_names
                  )
                  tmp_t.time_index = foreground_X.index
                  tmp_n[t] = tmp_t
              shap_explanations[h] = tmp_n
  
      return shap_explanations
  
imports: from enum import Enum
  from typing import Dict, NewType, Optional, Sequence, Union
  import matplotlib.pyplot
  import pandas
  import shap
  from sklearn.multioutput import MultiOutputRegressor
  from darts import TimeSeries
  from darts.explainability.explainability import _ForecastingModelExplainer
  from darts.explainability.explainability_result import ShapExplainabilityResult
  from darts.logging import get_logger, raise_if, raise_log
  from darts.models.forecasting.regression_model import RegressionModel
  from darts.utils.data.tabularization import create_lagged_prediction_data
label_desc: Use image node_id 2 for calling the _RegressionShapExplainers obj's underlying member method code with example usage: obj.shap_explanations(foreground_X, horizons, target_components) and returns: shap_explanations