code: def _test_framework_vs_numpy(self, classifier):
      # Test PGD with np.inf norm
      attack_np = ProjectedGradientDescentNumpy(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=0,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_np = attack_np.generate(self.x_train_mnist)
      x_test_adv_np = attack_np.generate(self.x_test_mnist)
  
      attack_fw = ProjectedGradientDescent(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=0,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_fw = attack_fw.generate(self.x_train_mnist)
      x_test_adv_fw = attack_fw.generate(self.x_test_mnist)
  
      # Test
      self.assertAlmostEqual(
          np.mean(x_train_adv_np - self.x_train_mnist),
          np.mean(x_train_adv_fw - self.x_train_mnist),
          places=6,
      )
      self.assertAlmostEqual(
          np.mean(x_test_adv_np - self.x_test_mnist),
          np.mean(x_test_adv_fw - self.x_test_mnist),
          places=6,
      )
  
      # Test PGD with L1 norm
      attack_np = ProjectedGradientDescentNumpy(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=1,
          targeted=False,
          num_random_init=0,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_np = attack_np.generate(self.x_train_mnist)
      x_test_adv_np = attack_np.generate(self.x_test_mnist)
  
      attack_fw = ProjectedGradientDescent(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=1,
          targeted=False,
          num_random_init=0,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_fw = attack_fw.generate(self.x_train_mnist)
      x_test_adv_fw = attack_fw.generate(self.x_test_mnist)
  
      # Test
      self.assertAlmostEqual(
          np.mean(x_train_adv_np - self.x_train_mnist),
          np.mean(x_train_adv_fw - self.x_train_mnist),
          places=6,
      )
      self.assertAlmostEqual(
          np.mean(x_test_adv_np - self.x_test_mnist),
          np.mean(x_test_adv_fw - self.x_test_mnist),
          places=6,
      )
  
      # Test PGD with L2 norm
      attack_np = ProjectedGradientDescentNumpy(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=2,
          targeted=False,
          num_random_init=0,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_np = attack_np.generate(self.x_train_mnist)
      x_test_adv_np = attack_np.generate(self.x_test_mnist)
  
      attack_fw = ProjectedGradientDescent(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=2,
          targeted=False,
          num_random_init=0,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_fw = attack_fw.generate(self.x_train_mnist)
      x_test_adv_fw = attack_fw.generate(self.x_test_mnist)
  
      # Test
      self.assertAlmostEqual(
          np.mean(x_train_adv_np - self.x_train_mnist),
          np.mean(x_train_adv_fw - self.x_train_mnist),
          places=6,
      )
      self.assertAlmostEqual(
          np.mean(x_test_adv_np - self.x_test_mnist),
          np.mean(x_test_adv_fw - self.x_test_mnist),
          places=6,
      )
  
      # Test PGD with True targeted
      attack_np = ProjectedGradientDescentNumpy(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=True,
          num_random_init=0,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_np = attack_np.generate(
          self.x_train_mnist, self.y_train_mnist
      )
      x_test_adv_np = attack_np.generate(
          self.x_test_mnist, self.y_test_mnist
      )
  
      attack_fw = ProjectedGradientDescent(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=True,
          num_random_init=0,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_fw = attack_fw.generate(
          self.x_train_mnist, self.y_train_mnist
      )
      x_test_adv_fw = attack_fw.generate(
          self.x_test_mnist, self.y_test_mnist
      )
  
      # Test
      self.assertAlmostEqual(
          np.mean(x_train_adv_np - self.x_train_mnist),
          np.mean(x_train_adv_fw - self.x_train_mnist),
          places=6,
      )
      self.assertAlmostEqual(
          np.mean(x_test_adv_np - self.x_test_mnist),
          np.mean(x_test_adv_fw - self.x_test_mnist),
          places=6,
      )
  
      # Test PGD with num_random_init=2
      master_seed(1234)
      attack_np = ProjectedGradientDescentNumpy(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=2,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_np = attack_np.generate(self.x_train_mnist)
      x_test_adv_np = attack_np.generate(self.x_test_mnist)
  
      master_seed(1234)
      attack_fw = ProjectedGradientDescent(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=2,
          batch_size=3,
          random_eps=False,
          verbose=False,
      )
      x_train_adv_fw = attack_fw.generate(self.x_train_mnist)
      x_test_adv_fw = attack_fw.generate(self.x_test_mnist)
  
      # Test
      self.assertAlmostEqual(
          np.mean(x_train_adv_np - self.x_train_mnist),
          np.mean(x_train_adv_fw - self.x_train_mnist),
          places=6,
      )
      self.assertAlmostEqual(
          np.mean(x_test_adv_np - self.x_test_mnist),
          np.mean(x_test_adv_fw - self.x_test_mnist),
          places=6,
      )
  
      # Test PGD with random_eps=True
      master_seed(1234)
      attack_np = ProjectedGradientDescentNumpy(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=0,
          batch_size=3,
          random_eps=True,
          verbose=False,
      )
      x_train_adv_np = attack_np.generate(self.x_train_mnist)
      x_test_adv_np = attack_np.generate(self.x_test_mnist)
  
      master_seed(1234)
      attack_fw = ProjectedGradientDescent(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=0,
          batch_size=3,
          random_eps=True,
          verbose=False,
      )
      x_train_adv_fw = attack_fw.generate(self.x_train_mnist)
      x_test_adv_fw = attack_fw.generate(self.x_test_mnist)
  
      # Test
      self.assertAlmostEqual(
          np.mean(x_train_adv_np - self.x_train_mnist),
          np.mean(x_train_adv_fw - self.x_train_mnist),
          places=6,
      )
      self.assertAlmostEqual(
          np.mean(x_test_adv_np - self.x_test_mnist),
          np.mean(x_test_adv_fw - self.x_test_mnist),
          places=6,
      )
  
      # Test the masking 1
      master_seed(1234)
      attack_np = ProjectedGradientDescentNumpy(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=1,
          batch_size=3,
          random_eps=True,
          verbose=False,
      )
  
      mask = np.random.binomial(
          n=1, p=0.5, size=np.prod(self.x_train_mnist.shape)
      )
      mask = mask.reshape(self.x_train_mnist.shape).astype(np.float32)
      x_train_adv_np = attack_np.generate(self.x_train_mnist, mask=mask)
  
      mask = np.random.binomial(
          n=1, p=0.5, size=np.prod(self.x_test_mnist.shape)
      )
      mask = mask.reshape(self.x_test_mnist.shape).astype(np.float32)
      x_test_adv_np = attack_np.generate(self.x_test_mnist, mask=mask)
  
      master_seed(1234)
      attack_fw = ProjectedGradientDescent(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=1,
          batch_size=3,
          random_eps=True,
          verbose=False,
      )
  
      mask = np.random.binomial(
          n=1, p=0.5, size=np.prod(self.x_train_mnist.shape)
      )
      mask = mask.reshape(self.x_train_mnist.shape).astype(np.float32)
      x_train_adv_fw = attack_fw.generate(self.x_train_mnist, mask=mask)
  
      mask = np.random.binomial(
          n=1, p=0.5, size=np.prod(self.x_test_mnist.shape)
      )
      mask = mask.reshape(self.x_test_mnist.shape).astype(np.float32)
      x_test_adv_fw = attack_fw.generate(self.x_test_mnist, mask=mask)
  
      # Test
      self.assertAlmostEqual(
          np.mean(x_train_adv_np - self.x_train_mnist),
          np.mean(x_train_adv_fw - self.x_train_mnist),
          places=6,
      )
      self.assertAlmostEqual(
          np.mean(x_test_adv_np - self.x_test_mnist),
          np.mean(x_test_adv_fw - self.x_test_mnist),
          places=6,
      )
  
      # Test the masking 2
      master_seed(1234)
      attack_np = ProjectedGradientDescentNumpy(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=1,
          batch_size=3,
          random_eps=True,
          verbose=False,
      )
  
      mask = np.random.binomial(
          n=1, p=0.5, size=np.prod(self.x_train_mnist.shape[1:])
      )
      mask = mask.reshape(self.x_train_mnist.shape[1:]).astype(
          np.float32
      )
      x_train_adv_np = attack_np.generate(self.x_train_mnist, mask=mask)
  
      mask = np.random.binomial(
          n=1, p=0.5, size=np.prod(self.x_test_mnist.shape[1:])
      )
      mask = mask.reshape(self.x_test_mnist.shape[1:]).astype(
          np.float32
      )
      x_test_adv_np = attack_np.generate(self.x_test_mnist, mask=mask)
  
      master_seed(1234)
      attack_fw = ProjectedGradientDescent(
          classifier,
          eps=1.0,
          eps_step=0.1,
          max_iter=5,
          norm=np.inf,
          targeted=False,
          num_random_init=1,
          batch_size=3,
          random_eps=True,
          verbose=False,
      )
  
      mask = np.random.binomial(
          n=1, p=0.5, size=np.prod(self.x_train_mnist.shape[1:])
      )
      mask = mask.reshape(self.x_train_mnist.shape[1:]).astype(
          np.float32
      )
      x_train_adv_fw = attack_fw.generate(self.x_train_mnist, mask=mask)
  
      mask = np.random.binomial(
          n=1, p=0.5, size=np.prod(self.x_test_mnist.shape[1:])
      )
      mask = mask.reshape(self.x_test_mnist.shape[1:]).astype(
          np.float32
      )
      x_test_adv_fw = attack_fw.generate(self.x_test_mnist, mask=mask)
  
      # Test
      self.assertAlmostEqual(
          np.mean(x_train_adv_np - self.x_train_mnist),
          np.mean(x_train_adv_fw - self.x_train_mnist),
          places=6,
      )
      self.assertAlmostEqual(
          np.mean(x_test_adv_np - self.x_test_mnist),
          np.mean(x_test_adv_fw - self.x_test_mnist),
          places=6,
      )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import numpy
  import tensorflow
  from art.attacks.evasion.projected_gradient_descent.projected_gradient_descent import ProjectedGradientDescent
  from art.attacks.evasion.projected_gradient_descent.projected_gradient_descent_numpy import ProjectedGradientDescentNumpy, ProjectedGradientDescentCommon
  from art.estimators.classification import KerasClassifier
  from art.estimators.estimator import BaseEstimator, LossGradientsMixin
  from art.utils import get_labels_np_array, random_targets
  from tests.attacks.utils import backend_test_classifier_type_check_fail
  from tests.utils import TestBase, get_image_classifier_kr, get_image_classifier_pt, get_image_classifier_tf, get_tabular_classifier_kr, get_tabular_classifier_pt, get_tabular_classifier_tf, master_seed
label_desc: Use image node_id 15 for calling the TestPGD obj's underlying member method code with example usage: obj._test_framework_vs_numpy(classifier) without return types