class_docstr: A unittest class for testing the NewtonFool attack.
docstr: Third test with the PyTorchClassifier.
  :return:
docstr_tok: ["Third","test","with","the","PyTorchClassifier",".",":","return",":"]
code: def test_5_pytorch_mnist(self):
      """
      Third test with the PyTorchClassifier.
      :return:
      """
      x_test = np.swapaxes(self.x_test_mnist, 1, 3).astype(np.float32)
      x_test_original = x_test.copy()
  
      # Build PyTorchClassifier
      ptc = get_image_classifier_pt()
  
      # Attack
      nf = NewtonFool(ptc, max_iter=5, batch_size=100, verbose=False)
      x_test_adv = nf.generate(x_test)
  
      self.assertFalse((x_test == x_test_adv).all())
  
      y_pred = ptc.predict(x_test)
      y_pred_adv = ptc.predict(x_test_adv)
      y_pred_bool = y_pred.max(axis=1, keepdims=1) == y_pred
      y_pred_max = y_pred.max(axis=1)
      y_pred_adv_max = y_pred_adv[y_pred_bool]
      self.assertTrue((y_pred_max >= 0.9 * y_pred_adv_max).all())
  
      # 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.newtonfool import NewtonFool
  from art.estimators.classification.classifier import ClassGradientsMixin
  from art.estimators.classification.keras import KerasClassifier
  from art.estimators.estimator import BaseEstimator
  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 4 for calling the TestNewtonFool obj's underlying member method code with example usage: obj.test_5_pytorch_mnist() without return types