def certify(
        self, pred_counts: "tf.Tensor", size_to_certify: int, label: np.ndarray | "tf.Tensor"
    ) -> tuple["tf.Tensor", "tf.Tensor", "tf.Tensor"]:
        """
        Checks if based on the predictions supplied the classifications over the ablated datapoints result in a
        certified prediction against a patch attack of size size_to_certify.

        :param preds: The cumulative predictions of the classifier over the ablation locations.
        :param size_to_certify: The size of the patch to check against.
        :param label: 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.
        """
        import tensorflow as tf

        result = tf.math.top_k(pred_counts, k=2)

        top_predicted_class, second_predicted_class = result.indices[:, 0], result.indices[:, 1]
        top_class_counts, second_class_counts = result.values[:, 0], result.values[:, 1]

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

        tie_break_certs = (
            (top_class_counts - second_class_counts) == 2 * (size_to_certify + self.ablation_size - 1)
        ) & (top_predicted_class < second_predicted_class)
        cert = tf.math.logical_or(certs, tie_break_certs)

        # NB, newer versions of pylint do not require this disabled.
        if label.ndim > 1:
            cert_and_correct = cert & (
                tf.math.argmax(label, axis=1) == tf.cast(top_predicted_class, dtype=tf.math.argmax(label, axis=1).dtype)
            )
        else:
            cert_and_correct = cert & (label == tf.cast(top_predicted_class, dtype=label.dtype))

        return cert, cert_and_correct, top_predicted_class

        Checks if based on the predictions supplied the classifications over the ablated datapoints result in a
        certified prediction against a patch attack of size size_to_certify.

        :param preds: The cumulative predictions of the classifier over the ablation locations.
        :param size_to_certify: The size of the patch to check against.
        :param label: 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/tensorflow.py