def fit_importances(
        self,
        x: np.ndarray | None = None,
        y: np.ndarray | None = None,
        importance_array: np.ndarray | None = None,
        normalize: bool | None = True,
    ):
        """
        This function allows one to easily calculate the feature importance vector using the pre-specified function,
        in case it wasn't passed at initialization.

        :param x: Design matrix of the dataset used to train the classifier.
        :param y: Labels of the dataset used to train the classifier.
        :param importance_array: Array providing features' importance score.
        :param normalize: Assure that feature importance values sum to 1.
        :return: LowProFool instance itself.
        """
        if importance_array is not None:
            # Use a pre-calculated vector of feature importance.
            if np.array(importance_array).shape == (self.n_features,):
                self.importance_vec = np.array(importance_array)
            else:  # pragma: no cover
                raise ValueError("Feature has to be one-dimensional array of size (n_features, ).")

        elif self.importance_vec is None:
            # Apply a function specified at the LowProFool instance initialization.
            self.__calculate_feature_importances(np.array(x), np.array(y))

        if normalize:
            # Make sure that importance vector sums to 1.
            if self.importance_vec is not None:
                self.importance_vec = np.array(self.importance_vec) / np.sum(self.importance_vec)
            else:
                raise ValueError("Unexpected `None` detected.")

        return self

        This function allows one to easily calculate the feature importance vector using the pre-specified function,
        in case it wasn't passed at initialization.

        :param x: Design matrix of the dataset used to train the classifier.
        :param y: Labels of the dataset used to train the classifier.
        :param importance_array: Array providing features' importance score.
        :param normalize: Assure that feature importance values sum to 1.
        :return: LowProFool instance itself.
        
art/attacks/evasion/lowprofool.py