class_docstr: Implementation of methods in Neural Cleanse: Identifying and Mitigating Backdoor Attacks in Neural Networks.
  Wang et al. (2019).
  
  | Paper link: https://people.cs.uchicago.edu/~ravenben/publications/pdf/backdoor-sp19.pdf
class_docstr_tok: ["Implementation","of","methods","in","Neural","Cleanse",":","Identifying","and","Mitigating","Backdoor","Attacks","in","Neural","Networks",".","Wang","et","al",".","(","2019",")",".","|","Paper","link",":","https",":","\/\/people.cs.uchicago.edu\/~ravenben\/publications\/pdf\/backdoor-sp19.pdf"]
docstr: Generate reverse-engineered backdoored examples using validation data
  :param x_val: validation data
  :param y_val: validation labels
  :return: a tuple containing (clean data, backdoored data, labels)
docstr_tok: ["Generate","reverse-engineered","backdoored","examples","using","validation","data",":","param","x_val",":","validation","data",":","param","y_val",":","validation","labels",":","return",":","a","tuple","containing","(","clean","data",",","backdoored","data",",","labels",")"]
code: def backdoor_examples(
      self, x_val: np.ndarray, y_val: np.ndarray
  ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
      """
      Generate reverse-engineered backdoored examples using validation data
      :param x_val: validation data
      :param y_val: validation labels
      :return: a tuple containing (clean data, backdoored data, labels)
      """
      clean_data_list = []
      example_data_list = []
      example_labels_list = []
  
      for backdoored_label, mask, pattern in self.outlier_detection(
          x_val, y_val
      ):
          data_for_class = np.copy(
              x_val[np.argmax(y_val, axis=1) == backdoored_label]
          )
          labels_for_class = np.copy(
              y_val[np.argmax(y_val, axis=1) == backdoored_label]
          )
  
          if len(data_for_class) == 0:
              logger.warning(
                  "No validation data exists for infected class: %s",
                  str(backdoored_label),
              )
  
          clean_data_list.append(np.copy(data_for_class))
          data_for_class = (1 - mask) * data_for_class + mask * pattern
          example_data_list.append(data_for_class)
          example_labels_list.append(labels_for_class)
  
      # If any backdoor examples were found, stack data into one array
      if example_data_list:
          clean_data = np.vstack(clean_data_list)
          example_data = np.vstack(example_data_list)
          example_labels = np.vstack(example_labels_list)
      else:
          clean_data = np.array(clean_data_list)
          example_data = np.array(example_data_list)
          example_labels = np.array(example_labels_list)
  
      return clean_data, example_data, example_labels
  
file_path: adversarial-robustness-toolbox/art/estimators/poison_mitigation/neural_cleanse/neural_cleanse.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Union, Tuple, List
  import numpy
  from art.estimators.certification.abstain import AbstainPredictorMixin
  from art.utils import to_categorical
label_desc: Use image node_id 9 for calling the NeuralCleanseMixin obj's underlying member method code with example usage: obj.backdoor_examples(x_val, y_val) and returns: clean_data,  example_data,  example_labels