code: def multiple_mini_batch_attack(
      adversary,
      loader,
      device="cuda",
      save_adv=False,
      norm=None,
      num_batch=None,
  ):
      lst_label = []
      lst_pred = []
      lst_advpred = []
      lst_dist = []
  
      _norm_convert_dict = {"Linf": "inf", "L2": 2, "L1": 1}
      if norm in _norm_convert_dict:
          norm = _norm_convert_dict[norm]
  
      if norm == "inf":
  
          def dist_func(x, y):
              return (x - y).view(x.size(0), -1).max(dim=1)[0]
  
      elif norm == 1 or norm == 2:
          from advertorch.utils import _get_norm_batch
  
          def dist_func(x, y):
              return _get_norm_batch(x - y, norm)
  
      else:
          assert norm is None
  
      idx_batch = 0
  
      for data, label in loader:
          data, label = data.to(device), label.to(device)
          adv = adversary.perturb(data, label)
          advpred = predict_from_logits(adversary.predict(adv))
          pred = predict_from_logits(adversary.predict(data))
          lst_label.append(label)
          lst_pred.append(pred)
          lst_advpred.append(advpred)
          if norm is not None:
              lst_dist.append(dist_func(data, adv))
  
          idx_batch += 1
          if idx_batch == num_batch:
              break
  
      return (
          torch.cat(lst_label),
          torch.cat(lst_pred),
          torch.cat(lst_advpred),
          torch.cat(lst_dist) if norm is not None else None,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import collections
  import numpy
  import torch
  from torch.distributions import laplace
  from torch.distributions import uniform
  from torch.nn.modules.loss import _Loss
  from advertorch.utils import clamp
  from advertorch.utils import clamp_by_pnorm
  from advertorch.utils import batch_multiply
  from advertorch.utils import normalize_by_pnorm
  from advertorch.utils import predict_from_logits
  from advertorch.loss import ZeroOneLoss
  from advertorch.attacks import Attack, LabelMixin
label_desc: Use image node_id 4 for calling a global function with example usage: multiple_mini_batch_attack(adversary, loader, device, save_adv, norm, num_batch) and returns: torch,  torch,  torch,  unknown, unknown, _get_norm_batch