code: def linf_clamp_(dx, x, eps, clip_min, clip_max):
      """Clamps perturbation `dx` to fit L_inf norm and image bounds.
  
      Limit the L_inf norm of `dx` to be <= `eps`, and the bounds of `x + dx`
      to be in `[clip_min, clip_max]`.
  
      :param dx: perturbation to be clamped (inplace).
      :param x: the image.
      :param eps: maximum possible L_inf.
      :param clip_min: upper bound of image values.
      :param clip_max: lower bound of image values.
  
      :return: the clamped perturbation `dx`.
      """
  
      dx_clamped = batch_clamp(eps, dx)
      x_adv = clamp(x + dx_clamped, clip_min, clip_max)
      # `dx` is changed *inplace* so the optimizer will keep
      # tracking it. the simplest mechanism for inplace was
      # adding the difference between the new value `x_adv - x`
      # and the old value `dx`.
      dx += x_adv - x - dx
      return dx
  
file_path: advertorch/advertorch/attacks/spsa.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import warnings
  import torch
  from .base import Attack
  from .base import LabelMixin
  from .utils import MarginalLoss
  from ..utils import is_float_or_torch_tensor, batch_clamp, clamp
label_desc: Use image node_id 1 for calling a global function with example usage: linf_clamp_(dx, x, eps, clip_min, clip_max) and returns: dx