class_docstr: SparseL1Descent Attack
  
  :param predict: forward pass function.
  :param loss_fn: loss function.
  :param eps: maximum distortion.
  :param nb_iter: number of iterations.
  :param eps_iter: attack step size.
  :param rand_init: (optional bool) random initialization.
  :param clip_min: mininum value per input dimension.
  :param clip_max: maximum value per input dimension.
  :param targeted: if the attack is targeted.
  :param l1_sparsity: proportion of zeros in gradient updates
class_docstr_tok: ["SparseL1Descent","Attack",":","param","predict",":","forward","pass","function",".",":","param","loss_fn",":","loss","function",".",":","param","eps",":","maximum","distortion",".",":","param","nb_iter",":","number","of","iterations",".",":","param","eps_iter",":","attack","step","size",".",":","param","rand_init",":","(","optional","bool",")","random","initialization",".",":","param","clip_min",":","mininum","value","per","input","dimension",".",":","param","clip_max",":","maximum","value","per","input","dimension",".",":","param","targeted",":","if","the","attack","is","targeted",".",":","param","l1_sparsity",":","proportion","of","zeros","in","gradient","updates"]
code: def __init__(
      self,
      predict,
      loss_fn=None,
      eps=0.3,
      nb_iter=40,
      eps_iter=0.01,
      rand_init=False,
      clip_min=0.0,
      clip_max=1.0,
      l1_sparsity=0.95,
      targeted=False,
  ):
      ord = 1
      super(SparseL1DescentAttack, self).__init__(
          predict=predict,
          loss_fn=loss_fn,
          eps=eps,
          nb_iter=nb_iter,
          eps_iter=eps_iter,
          rand_init=rand_init,
          clip_min=clip_min,
          clip_max=clip_max,
          targeted=targeted,
          ord=ord,
          l1_sparsity=l1_sparsity,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import numpy
  import torch
  import torch.nn
  from advertorch.utils import clamp
  from advertorch.utils import normalize_by_pnorm
  from advertorch.utils import clamp_by_pnorm
  from advertorch.utils import is_float_or_torch_tensor
  from advertorch.utils import batch_multiply
  from advertorch.utils import batch_clamp
  from advertorch.utils import replicate_input
  from advertorch.utils import batch_l1_proj
  from .base import Attack
  from .base import LabelMixin
  from .utils import rand_init_delta
label_desc: Use image node_id 1 to create a new SparseL1DescentAttack object from inherited base classes: PGDAttack with example: obj = SparseL1DescentAttack(predict, loss_fn, eps, nb_iter, eps_iter, rand_init, clip_min, clip_max, l1_sparsity, targeted)