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()
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.
        
darts/explainability/tft_explainer.py