class_docstr: The ElasticNet L1 Attack, https://arxiv.org/abs/1709.04114
  
  :param predict: forward pass function.
  :param num_classes: number of clasess.
  :param confidence: confidence of the adversarial examples.
  :param targeted: if the attack is targeted.
  :param learning_rate: the learning rate for the attack algorithm
  :param binary_search_steps: number of binary search times to find the
      optimum
  :param max_iterations: the maximum number of iterations
  :param abort_early: if set to true, abort early if getting stuck in local
      min
  :param initial_const: initial value of the constant c
  :param clip_min: mininum value per input dimension.
  :param clip_max: maximum value per input dimension.
  :param beta: hyperparameter trading off L2 minimization for L1 minimization
  :param decision_rule: EN or L1. Select final adversarial example from
                        all successful examples based on the least
                        elastic-net or L1 distortion criterion.
  :param loss_fn: loss function
class_docstr_tok: ["The","ElasticNet","L1","Attack",",","https",":","\/\/arxiv.org\/abs\/1709.04114",":","param","predict",":","forward","pass","function",".",":","param","num_classes",":","number","of","clasess",".",":","param","confidence",":","confidence","of","the","adversarial","examples",".",":","param","targeted",":","if","the","attack","is","targeted",".",":","param","learning_rate",":","the","learning","rate","for","the","attack","algorithm",":","param","binary_search_steps",":","number","of","binary","search","times","to","find","the","optimum",":","param","max_iterations",":","the","maximum","number","of","iterations",":","param","abort_early",":","if","set","to","true",",","abort","early","if","getting","stuck","in","local","min",":","param","initial_const",":","initial","value","of","the","constant","c",":","param","clip_min",":","mininum","value","per","input","dimension",".",":","param","clip_max",":","maximum","value","per","input","dimension",".",":","param","beta",":","hyperparameter","trading","off","L2","minimization","for","L1","minimization",":","param","decision_rule",":","EN","or","L1",".","Select","final","adversarial","example","from","all","successful","examples","based","on","the","least","elastic-net","or","L1","distortion","criterion",".",":","param","loss_fn",":","loss","function"]
code: def _loss_fn(
      self, output, y_onehot, l1dist, l2distsq, const, opt=False
  ):
      real = (y_onehot * output).sum(dim=1)
      other = (
          (1.0 - y_onehot) * output - (y_onehot * TARGET_MULT)
      ).max(1)[0]
  
      if self.targeted:
          loss_logits = clamp(other - real + self.confidence, min=0.0)
      else:
          loss_logits = clamp(real - other + self.confidence, min=0.0)
      loss_logits = torch.sum(const * loss_logits)
  
      loss_l2 = l2distsq.sum()
  
      if opt:
          loss = loss_logits + loss_l2
      else:
          loss_l1 = self.beta * l1dist.sum()
          loss = loss_logits + loss_l2 + loss_l1
      return loss
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import torch
  import torch.nn
  from advertorch.utils import calc_l2distsq
  from advertorch.utils import calc_l1dist
  from advertorch.utils import clamp
  from advertorch.utils import to_one_hot
  from advertorch.utils import replicate_input
  from .base import Attack
  from .base import LabelMixin
  from .utils import is_successful
label_desc: Use image node_id 2 for calling the ElasticNetL1Attack obj's underlying member method code with example usage: obj._loss_fn(output, y_onehot, l1dist, l2distsq, const, opt) and returns: loss