class_docstr: This class implements gradient attack method, and is the base of FGSM, BIM,
  ILCM, etc.
class_docstr_tok: ["This","class","implements","gradient","attack","method",",","and","is","the","base","of","FGSM",",","BIM",",","ILCM",",","etc","."]
code: def _norm(a, ord):
      if a.ndim == 1:
          return np.linalg.norm(a, ord=ord)
      if a.ndim == a.shape[0]:
          norm_shape = (a.ndim, reduce(np.dot, a.shape[1:]))
          norm_axis = 1
      else:
          norm_shape = (reduce(np.dot, a.shape[:-1]), a.ndim)
          norm_axis = 0
      return np.linalg.norm(
          a.reshape(norm_shape), ord=ord, axis=norm_axis
      )
  
imports: from __future__ import division
  from builtins import range
  import logging
  from collections import Iterable
  import numpy
  from .base import Attack
  from functools import reduce
label_desc: Use image node_id 3 for calling the GradientMethodAttack obj's underlying member method code with example usage: obj._norm(a, ord) and returns: np, np