def certify(
        self,
        pred_counts: torch.Tensor | np.ndarray,
        size_to_certify: int,
        label: torch.Tensor | np.ndarray,
    ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
        """
        Performs certification of the predictions

        :param pred_counts: The model predictions over the ablated data.
        :param size_to_certify: The patch size we wish to check certification against
        :param label: The ground truth labels
        :return: A tuple consisting of: the certified predictions,
                 the predictions which were certified and also correct,
                 and the most predicted class across the different ablations on the input.
        """

        if isinstance(pred_counts, np.ndarray):
            pred_counts = torch.from_numpy(pred_counts).to(self.device)

        if isinstance(label, np.ndarray):
            label = torch.from_numpy(label).to(self.device)

        # NB! argmax and kthvalue handle ties between predicted counts differently.
        # The original implementation: https://github.com/MadryLab/smoothed-vit/blob/main/src/utils/smoothing.py#L145
        # uses argmax for the model predictions
        # (later called y_smoothed https://github.com/MadryLab/smoothed-vit/blob/main/src/utils/smoothing.py#L230)
        # and kthvalue for the certified predictions.
        # to be consistent with the original implementation we also follow this here.
        top_predicted_class_argmax = torch.argmax(pred_counts, dim=1)

        num_of_classes = pred_counts.shape[-1]

        top_class_counts, top_predicted_class = pred_counts.kthvalue(num_of_classes, dim=1)
        second_class_counts, second_predicted_class = pred_counts.kthvalue(num_of_classes - 1, dim=1)

        cert = (top_class_counts - second_class_counts) > 2 * (size_to_certify + self.ablation_size - 1) ** 2

        cert_and_correct = cert & (label == top_predicted_class)

        if self.algorithm == "levine2020":
            tie_break_certs = (
                (top_class_counts - second_class_counts) == 2 * (size_to_certify + self.ablation_size - 1) ** 2
            ) & (top_predicted_class < second_predicted_class)
            cert = torch.logical_or(cert, tie_break_certs)
        return cert, cert_and_correct, top_predicted_class_argmax

        Performs certification of the predictions

        :param pred_counts: The model predictions over the ablated data.
        :param size_to_certify: The patch size we wish to check certification against
        :param label: The ground truth labels
        :return: A tuple consisting of: the certified predictions,
                 the predictions which were certified and also correct,
                 and the most predicted class across the different ablations on the input.
        
art/estimators/certification/derandomized_smoothing/ablators/pytorch.py