class_docstr: Pure Pytorch implementation of stripe/column ablation.
docstr: 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.
docstr_tok: ["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","."]
code: def certify(
      self,
      pred_counts: Union[torch.Tensor, np.ndarray],
      size_to_certify: int,
      label: Union[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)
  
      num_of_classes = pred_counts.shape[-1]
  
      # 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#L98
      # 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)
  
      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
      )
  
      if self.algorithm == "levine2020":
          tie_break_certs = (
              (top_class_counts - second_class_counts)
              == 2 * (size_to_certify + self.ablation_size - 1)
          ) & (top_predicted_class < second_predicted_class)
          cert = torch.logical_or(cert, tie_break_certs)
  
      cert_and_correct = cert & (label == top_predicted_class)
  
      return cert, cert_and_correct, top_predicted_class_argmax
  
imports: from typing import Optional, Union, Tuple
  import random
  import numpy
  import torch
  from art.estimators.certification.derandomized_smoothing.ablators.ablate import BaseAblator
label_desc: Use image node_id 4 for calling the ColumnAblatorPyTorch obj's underlying member method code with example usage: obj.certify(pred_counts, size_to_certify, label) and returns: cert,  cert_and_correct,  top_predicted_class_argmax