def __weighted_lp_norm_gradient(self, perturbations: np.ndarray) -> np.ndarray:
        """
        Gradient of the weighted Lp-space norm in regard to the data vector.

        :param perturbations: Perturbations of samples towards being adversarial.
        :return: Weighted Lp-norm gradients array.
        """
        norm = self.norm

        if isinstance(norm, (int, float)) and norm < np.inf and self.importance_vec is not None:
            numerator = (
                self.importance_vec * self.importance_vec * perturbations * np.power(np.abs(perturbations), norm - 2)
            )
            denominator = np.power(np.sum(np.power(self.importance_vec * perturbations, norm)), (norm - 1) / norm)

            numerator = np.where(denominator > 1e-10, numerator, np.zeros(numerator.shape[1]))
            denominator = np.where(denominator <= 1e-10, 1.0, denominator)

            return numerator / denominator

        # L-infinity norm (norm in ["inf", np.inf]).
        numerator = np.array(self.importance_vec * perturbations)
        optimum = np.max(np.abs(numerator))
        return np.where(abs(numerator) == optimum, np.sign(numerator), 0)

        Gradient of the weighted Lp-space norm in regard to the data vector.

        :param perturbations: Perturbations of samples towards being adversarial.
        :return: Weighted Lp-norm gradients array.
        
art/attacks/evasion/lowprofool.py