code: def compare_attacks(key, item):
      AdvertorchAttack = key
      fmodel = foolbox.models.PyTorchModel(
          model, bounds=(0, 1), num_classes=NUM_CLASS
      )
      fb_adversary = item["fb_class"](fmodel)
      fb_kwargs = merge2dicts(item["kwargs"], item["fb_kwargs"])
      at_kwargs = merge2dicts(item["kwargs"], item["at_kwargs"])
      thresholds = item["thresholds"]
      at_adversary = AdvertorchAttack(model, **at_kwargs)
      x_at = at_adversary.perturb(img_batch, label_batch)
      y_logits = model(img_batch)
      y_at_logits = model(x_at)
      y_pred = predict_from_logits(y_logits)
      y_at_pred = predict_from_logits(y_at_logits)
  
      fb_successed_once = False
      for i, (x_i, y_i) in enumerate(zip(img_batch, label_batch)):
          # rule out when classification is wrong or attack is
          # unsuccessful (we test if foolbox attacks fails here)
          if y_i != y_pred[i : i + 1][0]:
              continue
          if y_i == y_at_pred[i : i + 1][0]:
              continue
          np.random.seed(233333)
          with warnings.catch_warnings():
              warnings.simplefilter("ignore")
              x_fb = fb_adversary(
                  x_i.cpu().numpy(), label=int(y_i), **fb_kwargs
              )
          if x_fb is not None:
              compare_at_fb(x_at[i].cpu().numpy(), x_fb, **thresholds)
              fb_successed_once = True
  
      if not fb_successed_once:
          raise RuntimeError(
              "Foolbox never succeed, change your testing parameters!!!"
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import warnings
  import numpy
  import torch
  from advertorch.attacks import SinglePixelAttack
  from advertorch.attacks import LocalSearchAttack
  from advertorch.utils import predict_from_logits
  from advertorch.test_utils import merge2dicts
  from advertorch.test_utils import MLP
  from advertorch_examples.utils import TRAINED_MODEL_PATH
  from advertorch_examples.utils import get_mnist_test_loader
  import foolbox
  from foolbox.attacks.localsearch import SinglePixelAttack
  from foolbox.attacks.localsearch import LocalSearchAttack
label_desc: Use image node_id 2 for calling a global function with example usage: compare_attacks(key, item) without return types