code: def _calculate_benchmark_results(
      model,
      loader,
      attack_class,
      attack_kwargs,
      norm,
      device,
      num_batch,
  ):
      adversary = attack_class(model, **attack_kwargs)
      label, pred, advpred, dist = multiple_mini_batch_attack(
          adversary,
          loader,
          device=device,
          norm=norm,
          num_batch=num_batch,
      )
      accuracy = 100.0 * (label == pred).sum().item() / len(label)
      attack_success_rate = (
          100.0 * (label != advpred).sum().item() / len(label)
      )
      dist = (
          None
          if dist is None
          else dist[(label != advpred) & (label == pred)]
      )
      return len(label), accuracy, attack_success_rate, dist
  
file_path: advertorch/advertorch_examples/benchmark_utils.py
imports: import os
  import sys
  import torch
  import torchvision
  import advertorch
  from advertorch.attacks.utils import multiple_mini_batch_attack
label_desc: Use image node_id 2 for calling a global function with example usage: _calculate_benchmark_results(model, loader, attack_class, attack_kwargs, norm, device, num_batch) and returns: len,  accuracy,  attack_success_rate,  dist