code: def _test_mnist_targeted(self, classifier, x_test):
      x_test_original = x_test.copy()
  
      # Test FGSM with np.inf norm
      attack = BasicIterativeMethod(
          classifier,
          eps=1.0,
          eps_step=0.01,
          targeted=True,
          batch_size=128,
          verbose=False,
      )
      # y_test_adv = to_categorical((np.argmax(y_test, axis=1) + 1)  % 10, 10)
      pred_sort = classifier.predict(x_test).argsort(axis=1)
      y_test_adv = np.zeros((x_test.shape[0], 10))
      for i in range(x_test.shape[0]):
          y_test_adv[i, pred_sort[i, -2]] = 1.0
      x_test_adv = attack.generate(x_test, y=y_test_adv)
  
      self.assertFalse((x_test == x_test_adv).all())
  
      test_y_pred = get_labels_np_array(classifier.predict(x_test_adv))
  
      self.assertEqual(y_test_adv.shape, test_y_pred.shape)
      # This doesn't work all the time, especially with small networks
      self.assertGreaterEqual(
          (y_test_adv == test_y_pred).sum(), x_test.shape[0] // 2
      )
  
      # Check that x_test has not been modified by attack and classifier
      self.assertAlmostEqual(
          float(np.max(np.abs(x_test_original - x_test))),
          0.0,
          delta=0.00001,
      )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import numpy
  from art.attacks.evasion.iterative_method import BasicIterativeMethod
  from art.estimators.classification.keras 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
label_desc: Use image node_id 6 for calling the TestIterativeAttack obj's underlying member method code with example usage: obj._test_mnist_targeted(classifier, x_test) without return types