class_docstr: This class implements a variant of Projected Gradient Descent for the l1-norm
  (Tramer and Boneh 2019). The l1-norm case is more tricky than the l-inf and l2
  cases covered by the ProjectedGradientDescent class, because the steepest
  descent direction for the l1-norm is too sparse (it updates a single
  coordinate in the adversarial perturbation in each step). This attack has an
  additional parameter that controls the sparsity of the update step. For
  moderately sparse update steps, the attack vastly outperforms Projected
  Steepest Descent and is competitive with other attacks targeted at the l1-norm
  such as the ElasticNetMethod attack (which is much more computationally
  expensive).
  Paper link (Tramer and Boneh 2019): https://arxiv.org/pdf/1904.13000.pdf
  
  :param model: cleverhans.model.Model
  :param sess: optional tf.Session
  :param dtypestr: dtype of the data
  :param kwargs: passed through to super constructor
class_docstr_tok: ["This","class","implements","a","variant","of","Projected","Gradient","Descent","for","the","l1-norm","(","Tramer","and","Boneh","2019",")",".","The","l1-norm","case","is","more","tricky","than","the","l-inf","and","l2","cases","covered","by","the","ProjectedGradientDescent","class",",","because","the","steepest","descent","direction","for","the","l1-norm","is","too","sparse","(","it","updates","a","single","coordinate","in","the","adversarial","perturbation","in","each","step",")",".","This","attack","has","an","additional","parameter","that","controls","the","sparsity","of","the","update","step",".","For","moderately","sparse","update","steps",",","the","attack","vastly","outperforms","Projected","Steepest","Descent","and","is","competitive","with","other","attacks","targeted","at","the","l1-norm","such","as","the","ElasticNetMethod","attack","(","which","is","much","more","computationally","expensive",")",".","Paper","link","(","Tramer","and","Boneh","2019",")",":","https",":","\/\/arxiv.org\/pdf\/1904.13000.pdf",":","param","model",":","cleverhans.model.Model",":","param","sess",":","optional","tf.Session",":","param","dtypestr",":","dtype","of","the","data",":","param","kwargs",":","passed","through","to","super","constructor"]
docstr: Take in a dictionary of parameters and applies attack-specific checks
  before saving them as attributes.
  
  Attack-specific parameters:
  
  :param eps: (optional float) maximum distortion of adversarial example
              compared to original input
  :param eps_iter: (optional float) step size for each attack iteration
  :param nb_iter: (optional int) Number of attack iterations.
  :param y: (optional) A tensor with the true labels.
  :param y_target: (optional) A tensor with the labels to target. Leave
                   y_target=None if y is also set. Labels should be
                   one-hot-encoded.
  :param clip_min: (optional float) Minimum input component value
  :param clip_max: (optional float) Maximum input component value
  :param clip_grad: (optional bool) Ignore gradient components
                    at positions where the input is already at the boundary
                    of the domain, and the update step will get clipped out.
  :param grad_sparsity (optional) Relative sparsity of the gradient update
                       step, in percent. Only gradient values larger
                       than this percentile are retained. This parameter can
                       be a scalar, or a vector of the same length as the
                       input batch dimension.
  :param sanity_checks: bool Insert tf asserts checking values
      (Some tests need to run with no sanity checks because the
       tests intentionally configure the attack strangely)
docstr_tok: ["Take","in","a","dictionary","of","parameters","and","applies","attack-specific","checks","before","saving","them","as","attributes",".","Attack-specific","parameters",":",":","param","eps",":","(","optional","float",")","maximum","distortion","of","adversarial","example","compared","to","original","input",":","param","eps_iter",":","(","optional","float",")","step","size","for","each","attack","iteration",":","param","nb_iter",":","(","optional","int",")","Number","of","attack","iterations",".",":","param","y",":","(","optional",")","A","tensor","with","the","true","labels",".",":","param","y_target",":","(","optional",")","A","tensor","with","the","labels","to","target",".","Leave","y_target=None","if","y","is","also","set",".","Labels","should","be","one-hot-encoded",".",":","param","clip_min",":","(","optional","float",")","Minimum","input","component","value",":","param","clip_max",":","(","optional","float",")","Maximum","input","component","value",":","param","clip_grad",":","(","optional","bool",")","Ignore","gradient","components","at","positions","where","the","input","is","already","at","the","boundary","of","the","domain",",","and","the","update","step","will","get","clipped","out",".",":","param","grad_sparsity","(","optional",")","Relative","sparsity","of","the","gradient","update","step",",","in","percent",".","Only","gradient","values","larger","than","this","percentile","are","retained",".","This","parameter","can","be","a","scalar",",","or","a","vector","of","the","same","length","as","the","input","batch","dimension",".",":","param","sanity_checks",":","bool","Insert","tf","asserts","checking","values","(","Some","tests","need","to","run","with","no","sanity","checks","because","the","tests","intentionally","configure","the","attack","strangely",")"]
code: def parse_params(
      self,
      eps=10.0,
      eps_iter=1.0,
      nb_iter=20,
      y=None,
      clip_min=None,
      clip_max=None,
      y_target=None,
      rand_init=False,
      clip_grad=False,
      grad_sparsity=99,
      sanity_checks=True,
      **kwargs,
  ):
      """
      Take in a dictionary of parameters and applies attack-specific checks
      before saving them as attributes.
  
      Attack-specific parameters:
  
      :param eps: (optional float) maximum distortion of adversarial example
                  compared to original input
      :param eps_iter: (optional float) step size for each attack iteration
      :param nb_iter: (optional int) Number of attack iterations.
      :param y: (optional) A tensor with the true labels.
      :param y_target: (optional) A tensor with the labels to target. Leave
                       y_target=None if y is also set. Labels should be
                       one-hot-encoded.
      :param clip_min: (optional float) Minimum input component value
      :param clip_max: (optional float) Maximum input component value
      :param clip_grad: (optional bool) Ignore gradient components
                        at positions where the input is already at the boundary
                        of the domain, and the update step will get clipped out.
      :param grad_sparsity (optional) Relative sparsity of the gradient update
                           step, in percent. Only gradient values larger
                           than this percentile are retained. This parameter can
                           be a scalar, or a vector of the same length as the
                           input batch dimension.
      :param sanity_checks: bool Insert tf asserts checking values
          (Some tests need to run with no sanity checks because the
           tests intentionally configure the attack strangely)
      """
  
      # Save attack-specific parameters
      self.eps = eps
      self.rand_init = rand_init
      self.eps_iter = eps_iter
      self.nb_iter = nb_iter
      self.y = y
      self.y_target = y_target
      self.clip_min = clip_min
      self.clip_max = clip_max
      self.clip_grad = clip_grad
      self.grad_sparsity = grad_sparsity
  
      if isinstance(eps, float) and isinstance(eps_iter, float):
          # If these are both known at compile time, we can check before anything
          # is run. If they are tf, we can't check them yet.
          assert eps_iter <= eps, (eps_iter, eps)
  
      if self.y is not None and self.y_target is not None:
          raise ValueError("Must not set both y and y_target")
  
      if self.clip_grad and (
          self.clip_min is None or self.clip_max is None
      ):
          raise ValueError(
              "Must set clip_min and clip_max if clip_grad is set"
          )
  
      # The grad_sparsity argument governs the sparsity of the gradient
      # update. It indicates the percentile value above which gradient entries
      # are retained. It can be specified as a scalar or as a 1-dimensional
      # vector of the same size as the input's batch dimension.
      if isinstance(self.grad_sparsity, int) or isinstance(
          self.grad_sparsity, float
      ):
          if not 0 < self.grad_sparsity < 100:
              raise ValueError("grad_sparsity should be in (0, 100)")
      else:
          self.grad_sparsity = tf.convert_to_tensor(self.grad_sparsity)
          if len(self.grad_sparsity.shape) > 1:
              raise ValueError(
                  "grad_sparsity should either be a scalar or a vector"
              )
  
      self.sanity_checks = sanity_checks
  
      if len(kwargs.keys()) > 0:
          warnings.warn(
              "kwargs is unused and will be removed on or after "
              "2019-04-26."
          )
  
      return True
  
file_path: cleverhans/cleverhans_v3.1.0/cleverhans/attacks/sparse_l1_descent.py
imports: import warnings
  from distutils.version import LooseVersion
  import tensorflow
  from cleverhans.attacks.attack import Attack
  from cleverhans import utils_tf
  from cleverhans.utils_tf import clip_eta, random_lp_vector
  from cleverhans.compat import reduce_max, reduce_sum, softmax_cross_entropy_with_logits
label_desc: Use image node_id 3 for calling the SparseL1Descent obj's underlying member method code with example usage: obj.parse_params(eps, eps_iter, nb_iter, y, clip_min, clip_max, y_target, rand_init, clip_grad, grad_sparsity, sanity_checks) and returns: True