def _test_attack(self, classifier, x_test, y_test, targeted):
        """
        Test with the Threshold Attack
        :return:
        """
        x_test_original = x_test.copy()

        if targeted:
            # Generate random target classes
            class_y_test = np.argmax(y_test, axis=1)
            nb_classes = np.unique(class_y_test).shape[0]
            np.random.seed(seed=487)
            targets = np.random.randint(nb_classes, size=self.n_test)
            for i in range(self.n_test):
                if class_y_test[i] == targets[i]:
                    targets[i] -= 1
        else:
            targets = y_test

        for es in [1]:  # Option 0 is not easy to reproduce reliably, we should consider it at a later time
            df = ThresholdAttack(classifier, th=128, es=es, max_iter=10, targeted=targeted, verbose=False)
            x_test_adv = df.generate(x_test_original, targets)

            np.testing.assert_raises(AssertionError, np.testing.assert_array_equal, x_test, x_test_adv)
            self.assertFalse((0.0 == x_test_adv).all())

            y_pred = get_labels_np_array(classifier.predict(x_test_adv))

            accuracy = np.sum(np.argmax(y_pred, axis=1) == np.argmax(self.y_test_mnist, axis=1)) / self.n_test
            logger.info("Accuracy on adversarial examples: %.2f%%", (accuracy * 100))

        # 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)

        Test with the Threshold Attack
        :return:
        
tests/attacks/test_threshold_attack.py