code: def get_perturbation_metric(
      x_original, x_adv, y_pred, y_pred_adv, ord=2
  ):
      idxs = np.argmax(y_pred_adv, axis=1) != np.argmax(y_pred, axis=1)
  
      if np.sum(idxs) == 0.0:
          return 0
  
      perts_norm = la.norm(
          (x_adv - x_original).reshape(x_original.shape[0], -1),
          ord,
          axis=1,
      )
      perts_norm = perts_norm[idxs]
  
      return np.mean(
          perts_norm
          / la.norm(
              x_original[idxs].reshape(np.sum(idxs), -1), ord, axis=1
          )
      )
  
file_path: adversarial-robustness-toolbox/utils/mlops/kubeflow/robustness_evaluation_fgsm_pytorch/src/robustness_util.py
imports: import numpy
  import numpy.linalg
  import torch
  import torch.utils.data
  from torch.autograd import Variable
label_desc: Use image node_id 3 for calling a global function with example usage: get_perturbation_metric(x_original, x_adv, y_pred, y_pred_adv, ord) and returns: np, int