def _modify_classifier(
        self, p_classifier: PyTorchClassifier, list_keys: list[str], w_perturb: dict[str, "torch.Tensor"], op: str
    ) -> None:
        """
        Modify the model's weight parameters according to the weight perturbations.

        :param p_classifier: model for awp protocol.
        :param list_keys: List of model parameters' names
        :param w_perturb: dictionary containing model parameters' names as keys and model parameters as values
        :param op: controls whether weight perturbation will be added or subtracted from model parameters
        """
        import torch

        if op.lower() == "add":
            c_mult = 1.0
        elif op.lower() == "subtract":
            c_mult = -1.0
        else:
            raise ValueError("Incorrect op provided for weight perturbation. 'op' must be among 'add' and 'subtract'.")
        with torch.no_grad():
            for name, param in p_classifier.model.named_parameters():
                if name in list_keys:
                    param.add_(c_mult * self._gamma * w_perturb[name])

        Modify the model's weight parameters according to the weight perturbations.

        :param p_classifier: model for awp protocol.
        :param list_keys: List of model parameters' names
        :param w_perturb: dictionary containing model parameters' names as keys and model parameters as values
        :param op: controls whether weight perturbation will be added or subtracted from model parameters
        
art/defences/trainer/adversarial_trainer_awp_pytorch.py