code: def test_generate(
      art_warning,
      fix_get_mnist_subset,
      image_dl_estimator_for_attack,
      norm,
  ):
      try:
          classifier = image_dl_estimator_for_attack(SquareAttack)
  
          attack = SquareAttack(
              estimator=classifier,
              norm=norm,
              max_iter=5,
              eps=0.3,
              p_init=0.8,
              nb_restarts=1,
              verbose=False,
          )
  
          (
              x_train_mnist,
              y_train_mnist,
              x_test_mnist,
              y_test_mnist,
          ) = fix_get_mnist_subset
  
          x_train_mnist_adv = attack.generate(
              x=x_train_mnist, y=y_train_mnist
          )
  
          if norm == "inf":
              expected_mean = 0.053533513
              expected_max = 0.3
          elif norm == 2:
              expected_mean = 0.00073682
              expected_max = 0.25
          else:
              raise ValueError("Value of `norm` not recognized.")
  
          assert np.mean(
              np.abs(x_train_mnist_adv - x_train_mnist)
          ) == pytest.approx(expected_mean, abs=0.025)
          assert np.max(
              np.abs(x_train_mnist_adv - x_train_mnist)
          ) == pytest.approx(expected_max, abs=0.05)
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/attacks/evasion/test_square_attack.py
imports: import logging
  import pytest
  import numpy
  from art.attacks.evasion import SquareAttack
  from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
  from tests.attacks.utils import backend_test_classifier_type_check_fail
  from tests.utils import ARTTestException
label_desc: Use image node_id 2 for calling a global function with example usage: test_generate(art_warning, fix_get_mnist_subset, image_dl_estimator_for_attack, norm) without return types