Compute the distance between two images.

def compute_distance(x_ori, x_pert, constraint='l2'):
  """ Compute the distance between two images. """
  if constraint == 'l2':
    dist = np.linalg.norm(x_ori - x_pert)
  elif constraint == 'linf':
    dist = np.max(abs(x_ori - x_pert))
  return dist