docstr: Returns the encoder or decoder variable of the TFT model.
  
  Parameters
  ----------
  weights
      The weights of the encoder or decoder of the trained TFT model.
  names
      The encoder or decoder names saved in the TFT model class.
  n_decimals
      The number of decimals to round the importance to.
  
  Returns
  -------
  pd.DataFrame
      The importance of the variables.
docstr_tok: ["Returns","the","encoder","or","decoder","variable","of","the","TFT","model",".","Parameters","--","--","--","--","--","weights","The","weights","of","the","encoder","or","decoder","of","the","trained","TFT","model",".","names","The","encoder","or","decoder","names","saved","in","the","TFT","model","class",".","n_decimals","The","number","of","decimals","to","round","the","importance","to",".","Returns","--","--","--","-","pd.DataFrame","The","importance","of","the","variables","."]
code: def _get_importance(
      self,
      weight: Tensor,
      names: List[str],
      n_decimals=3,
  ) -> pd.DataFrame:
      """Returns the encoder or decoder variable of the TFT model.
  
      Parameters
      ----------
      weights
          The weights of the encoder or decoder of the trained TFT model.
      names
          The encoder or decoder names saved in the TFT model class.
      n_decimals
          The number of decimals to round the importance to.
  
      Returns
      -------
      pd.DataFrame
          The importance of the variables.
      """
      if weight is None:
          return pd.DataFrame()
  
      # static covariates aggregation needs expansion in first dimension
      if weight.ndim == 3:
          weight = weight.unsqueeze(1)
  
      # transform the encoder/decoder weights to percentages, rounded to n_decimals
      weights_percentage = (
          weight.detach()
          .cpu()
          .numpy()
          .mean(axis=1)
          .squeeze(axis=1)
          .round(n_decimals)
          * 100
      )
      # create a dataframe with the variable names and the weights
      name_mapping = self._name_mapping
      importance = pd.DataFrame(
          weights_percentage,
          columns=[name_mapping[name] for name in names],
      )
  
      # return the importance sorted descending
      return (
          importance.transpose()
          .sort_values(0, ascending=True)
          .transpose()
      )
  
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 8 for calling the TFTExplainer obj's underlying member method code with example usage: obj._get_importance(weight, names, n_decimals) and returns: importance, pd