code: def project(
      original_image, perturbed_images, alphas, shape, constraint
  ):
      """Projection onto given l2 / linf balls in a batch."""
      alphas = alphas.view((alphas.shape[0],) + (1,) * (len(shape) - 1))
      if constraint == 2:
          projected = (
              1 - alphas
          ) * original_image + alphas * perturbed_images
      elif constraint == np.inf:
          projected = torch.clamp(
              perturbed_images,
              original_image - alphas,
              original_image + alphas,
          )
      return projected
  
file_path: cleverhans/cleverhans/torch/attacks/hop_skip_jump_attack.py
imports: import numpy
  import torch
label_desc: Use image node_id 4 for calling a global function with example usage: project(original_image, perturbed_images, alphas, shape, constraint) and returns: projected