class_docstr: The attack that uses L-BFGS to minimize the distance of the original
  and perturbed images
  
  :param predict: forward pass function.
  :param num_classes: number of clasess.
  :param batch_size: number of samples in the batch
  :param binary_search_steps: number of binary search times to find the
      optimum
  :param max_iterations: the maximum number of iterations
  :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 loss_fn: loss function
  :param targeted: if the attack is targeted.
class_docstr_tok: ["The","attack","that","uses","L-BFGS","to","minimize","the","distance","of","the","original","and","perturbed","images",":","param","predict",":","forward","pass","function",".",":","param","num_classes",":","number","of","clasess",".",":","param","batch_size",":","number","of","samples","in","the","batch",":","param","binary_search_steps",":","number","of","binary","search","times","to","find","the","optimum",":","param","max_iterations",":","the","maximum","number","of","iterations",":","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","loss_fn",":","loss","function",":","param","targeted",":","if","the","attack","is","targeted","."]
code: def _update_if_better(
      self,
      adv_img,
      labs,
      output,
      dist,
      batch_size,
      final_l2dists,
      final_labels,
      final_advs,
  ):
      for ii in range(batch_size):
          target_label = labs[ii]
          output_logits = output[ii]
          _, output_label = torch.max(output_logits, 0)
          di = dist[ii]
          if (
              di < final_l2dists[ii]
              and output_label.item() == target_label
          ):
              final_l2dists[ii] = di
              final_labels[ii] = output_label
              final_advs[ii] = adv_img[ii]
  
file_path: advertorch/advertorch/attacks/lbfgs.py
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.functional
  from advertorch.utils import calc_l2distsq
  from .base import Attack
  from .base import LabelMixin
label_desc: Use image node_id 2 for calling the LBFGSAttack obj's underlying member method code with example usage: obj._update_if_better(adv_img, labs, output, dist, batch_size, final_l2dists, final_labels, final_advs) without return types