class_docstr: Implementation of the Copycat CNN attack from Rodrigues Correia-Silva et al. (2018).
  
  | Paper link: https://arxiv.org/abs/1806.05476
class_docstr_tok: ["Implementation","of","the","Copycat","CNN","attack","from","Rodrigues","Correia-Silva","et","al",".","(","2018",")",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1806.05476"]
docstr: Extract a thieved classifier.
  
  :param x: An array with the source input to the victim classifier.
  :param y: Target values (class labels) one-hot-encoded of shape (nb_samples, nb_classes) or indices of shape
            (nb_samples,). Not used in this attack.
  :param thieved_classifier: A classifier to be stolen, currently always trained on one-hot labels.
  :type thieved_classifier: :class:`.Classifier`
  :return: The stolen classifier.
docstr_tok: ["Extract","a","thieved","classifier",".",":","param","x",":","An","array","with","the","source","input","to","the","victim","classifier",".",":","param","y",":","Target","values","(","class","labels",")","one-hot-encoded","of","shape","(","nb_samples",",","nb_classes",")","or","indices","of","shape","(","nb_samples",",",")",".","Not","used","in","this","attack",".",":","param","thieved_classifier",":","A","classifier","to","be","stolen",",","currently","always","trained","on","one-hot","labels",".",":","type","thieved_classifier",":",":","class",":","`",".Classifier","`",":","return",":","The","stolen","classifier","."]
code: def extract(
      self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs
  ) -> "CLASSIFIER_TYPE":
      """
      Extract a thieved classifier.
  
      :param x: An array with the source input to the victim classifier.
      :param y: Target values (class labels) one-hot-encoded of shape (nb_samples, nb_classes) or indices of shape
                (nb_samples,). Not used in this attack.
      :param thieved_classifier: A classifier to be stolen, currently always trained on one-hot labels.
      :type thieved_classifier: :class:`.Classifier`
      :return: The stolen classifier.
      """
      # Warning to users if y is not None
      if y is not None:  # pragma: no cover
          logger.warning(
              "This attack does not use the provided label y."
          )
  
      # Check the size of the source input vs nb_stolen
      if x.shape[0] < self.nb_stolen:  # pragma: no cover
          logger.warning(
              "The size of the source input is smaller than the expected number of queries submitted "
              "to the victim classifier."
          )
  
      # Check if there is a thieved classifier provided for training
      thieved_classifier = kwargs["thieved_classifier"]
      if thieved_classifier is None or not isinstance(
          thieved_classifier, ClassifierMixin
      ):  # pragma: no cover
          raise ValueError("A thieved classifier is needed.")
  
      # Select data to attack
      selected_x = self._select_data(x)
  
      # Query the victim classifier
      fake_labels = self._query_label(selected_x)
  
      # Train the thieved classifier
      thieved_classifier.fit(  # type: ignore
          x=selected_x,
          y=fake_labels,
          batch_size=self.batch_size_fit,
          nb_epochs=self.nb_epochs,
      )
  
      return thieved_classifier
  
file_path: adversarial-robustness-toolbox/art/attacks/extraction/copycat_cnn.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, TYPE_CHECKING
  import numpy
  from art.config import ART_NUMPY_DTYPE
  from art.attacks.attack import ExtractionAttack
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassifierMixin
  from art.utils import to_categorical
label_desc: Use image node_id 2 for calling the CopycatCNN obj's underlying member method code with example usage: obj.extract(x, y) and returns: thieved_classifier