class_docstr: Implementation of (De)Randomized Smoothing applied to classifier predictions as introduced
  in Levine et al. (2020).
  
  | Paper link: https://arxiv.org/abs/2002.10733
class_docstr_tok: ["Implementation","of","(","De",")","Randomized","Smoothing","applied","to","classifier","predictions","as","introduced","in","Levine","et","al",".","(","2020",")",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/2002.10733"]
docstr: Evaluates the normal and certified performance over the supplied data.
  
  :param x: Evaluation data.
  :param y: Evaluation labels.
  :param size_to_certify: The size of the patch to certify against.
                          If not provided will default to the ablation size.
  :param batch_size: batch size when evaluating.
  :param verbose: If to display the progress bar
  :return: The accuracy and certified accuracy over the dataset
docstr_tok: ["Evaluates","the","normal","and","certified","performance","over","the","supplied","data",".",":","param","x",":","Evaluation","data",".",":","param","y",":","Evaluation","labels",".",":","param","size_to_certify",":","The","size","of","the","patch","to","certify","against",".","If","not","provided","will","default","to","the","ablation","size",".",":","param","batch_size",":","batch","size","when","evaluating",".",":","param","verbose",":","If","to","display","the","progress","bar",":","return",":","The","accuracy","and","certified","accuracy","over","the","dataset"]
code: def eval_and_certify(
      self,
      x: np.ndarray,
      y: np.ndarray,
      size_to_certify: int,
      batch_size: int = 128,
      verbose: bool = True,
  ) -> Tuple["tf.Tensor", "tf.Tensor"]:
      """
      Evaluates the normal and certified performance over the supplied data.
  
      :param x: Evaluation data.
      :param y: Evaluation labels.
      :param size_to_certify: The size of the patch to certify against.
                              If not provided will default to the ablation size.
      :param batch_size: batch size when evaluating.
      :param verbose: If to display the progress bar
      :return: The accuracy and certified accuracy over the dataset
      """
      import tensorflow as tf
  
      y = check_and_transform_label_format(
          y, nb_classes=self.nb_classes
      )
  
      # Apply preprocessing
      x_preprocessed, y_preprocessed = self._apply_preprocessing(
          x, y, fit=True
      )
  
      num_batch = int(np.ceil(len(x_preprocessed) / float(batch_size)))
      pbar = tqdm(range(num_batch), disable=not verbose)
      accuracy = tf.constant(np.array(0.0), dtype=tf.dtypes.int32)
      cert_sum = tf.constant(np.array(0.0), dtype=tf.dtypes.int32)
      n_samples = 0
  
      for m in pbar:
          if m == (num_batch - 1):
              i_batch = np.copy(x_preprocessed[m * batch_size :])
              o_batch = y_preprocessed[m * batch_size :]
          else:
              i_batch = np.copy(
                  x_preprocessed[m * batch_size : (m + 1) * batch_size]
              )
              o_batch = y_preprocessed[
                  m * batch_size : (m + 1) * batch_size
              ]
  
          pred_counts = self.predict(i_batch)
  
          (
              _,
              cert_and_correct,
              top_predicted_class,
          ) = self.ablator.certify(
              pred_counts,
              size_to_certify=size_to_certify,
              label=o_batch,
          )
          cert_sum += tf.math.reduce_sum(
              tf.where(cert_and_correct, 1, 0)
          )
          accuracy += tf.math.reduce_sum(
              tf.where(
                  top_predicted_class == np.argmax(o_batch, axis=-1),
                  1,
                  0,
              )
          )
          n_samples += len(cert_and_correct)
  
          pbar.set_description(
              f"Normal Acc {accuracy / n_samples:.3f} "
              f"Cert Acc {cert_sum / n_samples:.3f}"
          )
      return (accuracy / n_samples), (cert_sum / n_samples)
  
file_path: adversarial-robustness-toolbox/art/estimators/certification/derandomized_smoothing/tensorflow.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Callable, List, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from tqdm import tqdm
  from art.estimators.certification.derandomized_smoothing.derandomized import DeRandomizedSmoothingMixin
  from art.estimators.classification.tensorflow import TensorFlowV2Classifier
  from art.utils import check_and_transform_label_format
label_desc: Use image node_id 5 for calling the TensorFlowV2DeRandomizedSmoothing obj's underlying member method code with example usage: obj.eval_and_certify(x, y, size_to_certify, batch_size, verbose) and returns: unknown,  unknown