class_docstr: Implementation of Randomized Smoothing applied to classifier predictions and gradients, as introduced
  in Cohen et al. (2019).
  
  | Paper link: https://arxiv.org/abs/1902.02918
class_docstr_tok: ["Implementation","of","Randomized","Smoothing","applied","to","classifier","predictions","and","gradients",",","as","introduced","in","Cohen","et","al",".","(","2019",")",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1902.02918"]
docstr: Makes predictions and then converts probability distribution to counts.
  
  :param x: Sample input with shape as expected by the model.
  :param n: Number of noisy samples to create.
  :param batch_size: Size of batches.
  :return: Array of counts with length equal to number of columns of `x`.
docstr_tok: ["Makes","predictions","and","then","converts","probability","distribution","to","counts",".",":","param","x",":","Sample","input","with","shape","as","expected","by","the","model",".",":","param","n",":","Number","of","noisy","samples","to","create",".",":","param","batch_size",":","Size","of","batches",".",":","return",":","Array","of","counts","with","length","equal","to","number","of","columns","of","`","x","`","."]
code: def _prediction_counts(
      self,
      x: np.ndarray,
      n: Optional[int] = None,
      batch_size: int = 128,
  ) -> np.ndarray:
      """
      Makes predictions and then converts probability distribution to counts.
  
      :param x: Sample input with shape as expected by the model.
      :param n: Number of noisy samples to create.
      :param batch_size: Size of batches.
      :return: Array of counts with length equal to number of columns of `x`.
      """
      # sample and predict
      x_new = self._noisy_samples(x, n=n)
      predictions = self._predict_classifier(
          x=x_new, batch_size=batch_size, training_mode=False
      )
  
      # convert to binary predictions
      idx = np.argmax(predictions, axis=-1)
      pred = np.zeros(predictions.shape)
      pred[np.arange(pred.shape[0]), idx] = 1
  
      # get class counts
      counts = np.sum(pred, axis=0)
  
      return counts
  
file_path: adversarial-robustness-toolbox/art/estimators/certification/randomized_smoothing/randomized_smoothing.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from abc import ABC
  import logging
  from typing import Optional, Tuple
  import numpy
  from scipy.stats import norm
  from tqdm.auto import tqdm
  from art.config import ART_NUMPY_DTYPE
label_desc: Use image node_id 8 for calling the RandomizedSmoothingMixin obj's underlying member method code with example usage: obj._prediction_counts(x, n, batch_size) and returns: counts