class_docstr: Uses Adam to minimize the CW L2 objective function
  
  Paper link: https://arxiv.org/abs/1608.04644
class_docstr_tok: ["Uses","Adam","to","minimize","the","CW","L2","objective","function","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1608.04644"]
docstr: create constrained and distance with img_0_1(0,1)
docstr_tok: ["create","constrained","and","distance","with","img_0_1","(","0,1",")"]
code: def _constrain_cwb(self, img_0_1):
      """
      create constrained and distance with img_0_1(0,1)
      """
      # img to (-1, 1)
      self.y = 2 * img_0_1 - 1
      # compute arctan for y to get w
      self.xplus1 = 1 + self.y
      self.xminus1 = 1 - self.y
      self.ln = fluid.layers.log(self.xplus1 / self.xminus1)
      self.w = fluid.layers.scale(x=self.ln, scale=0.5)
      self.w_ad = self.w + self.ad_perturbation
  
      self.tanh_constrained = (fluid.layers.tanh(self.w_ad) + 1) * 0.5
      self.tanh_original = (fluid.layers.tanh(self.w) + 1) * 0.5
      # restore the range as original img
      self.constrained = self.reconstruct(self.tanh_constrained)
      self.original = self.reconstruct(self.tanh_original)
      # L2
      self.sub = fluid.layers.elementwise_sub(
          self.constrained, self.original
      )
      self.squared = fluid.layers.elementwise_mul(self.sub, self.sub)
      self.distance_L2 = fluid.layers.reduce_sum(self.squared)
  
      return self.constrained, self.distance_L2
  
file_path: AdvBox/adversarialbox/attacks/cw.py
imports: from __future__ import division
  from __future__ import print_function
  from builtins import range
  import logging
  import numpy
  import paddle.fluid
  from .base import Attack
label_desc: Use image node_id 4 for calling the CW_L2_Attack obj's underlying member method code with example usage: obj._constrain_cwb(img_0_1) and returns: self,  self