class_docstr: A unittest class for testing Randomized Smoothing as a post-processing step for classifiers.
docstr: Test with a KerasClassifier.
  :return:
docstr_tok: ["Test","with","a","KerasClassifier",".",":","return",":"]
code: def test_keras(self):
      """
      Test with a KerasClassifier.
      :return:
      """
      # Build KerasClassifier
      krc = get_image_classifier_kr_tf(loss_type="label")
  
      # Get MNIST
      (x_train, y_train), (_, _) = self.mnist
      target_idx = 9
      target = np.zeros(10)
      target[target_idx] = 1
      target2 = np.zeros(10)
      target2[(target_idx + 1) % 10] = 1
  
      backdoor = PoisoningAttackBackdoor(add_pattern_bd)
  
      emb_attack = PoisoningAttackAdversarialEmbedding(
          krc, backdoor, 2, target
      )
      classifier = emb_attack.poison_estimator(
          x_train, y_train, nb_epochs=NB_EPOCHS
      )
  
      data, labels, bd = emb_attack.get_training_data()
      self.assertEqual(x_train.shape, data.shape)
      self.assertEqual(y_train.shape, labels.shape)
      self.assertEqual(bd.shape, (len(x_train), 2))
  
      # Assert successful cloning of classifier model
      self.assertTrue(classifier is not krc)
  
      emb_attack2 = PoisoningAttackAdversarialEmbedding(
          krc, backdoor, 2, [(target, target2)]
      )
      _ = emb_attack2.poison_estimator(
          x_train, y_train, nb_epochs=NB_EPOCHS
      )
  
      data, labels, bd = emb_attack2.get_training_data()
      self.assertEqual(x_train.shape, data.shape)
      self.assertEqual(y_train.shape, labels.shape)
      self.assertEqual(bd.shape, (len(x_train), 2))
  
      _ = PoisoningAttackAdversarialEmbedding(
          krc, backdoor, 2, [(target, target2)], pp_poison=[0.4]
      )
  
file_path: adversarial-robustness-toolbox/tests/attacks/test_adversarial_embedding.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  import unittest
  import numpy
  from art.attacks.poisoning.backdoor_attack import PoisoningAttackBackdoor
  from art.attacks.poisoning.adversarial_embedding_attack import PoisoningAttackAdversarialEmbedding
  from art.attacks.poisoning.perturbations import add_pattern_bd
  from art.utils import load_dataset
  from tests.utils import master_seed, get_image_classifier_kr_tf
label_desc: Use image node_id 3 for calling the TestAdversarialEmbedding obj's underlying member method code with example usage: obj.test_keras() without return types