class_docstr: A unittest class for testing Randomized Smoothing as a post-processing step for classifiers.
code: def test_errors(self):
      krc = get_image_classifier_kr_tf(loss_type="function")
      krc_valid = get_image_classifier_kr_tf(loss_type="label")
      backdoor = PoisoningAttackBackdoor(add_pattern_bd)
      target_idx = 9
      target = np.zeros(10)
      target[target_idx] = 1
      target2 = np.zeros(10)
      target2[(target_idx + 1) % 10] = 1
  
      # invalid loss function
      with self.assertRaises(TypeError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc, backdoor, 2, target
          )
  
      # feature layer not real name
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, "not a layer", target
          )
  
      # feature layer out of range
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, 20, target
          )
  
      # target misshaped
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, 20, np.expand_dims(target, axis=0)
          )
  
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, 20, [target]
          )
  
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, 20, target, regularization=-1
          )
  
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, 20, target, discriminator_layer_1=-1
          )
  
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, 20, target, discriminator_layer_2=-1
          )
  
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, 20, target, pp_poison=-1
          )
  
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid, backdoor, 20, [(target, target2)], pp_poison=[]
          )
  
      with self.assertRaises(ValueError):
          _ = PoisoningAttackAdversarialEmbedding(
              krc_valid,
              backdoor,
              20,
              [(target, target2)],
              pp_poison=[-1],
          )
  
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 4 for calling the TestAdversarialEmbedding obj's underlying member method code with example usage: obj.test_errors() without return types