class_docstr: Composite Attack class with 1+ base attacks and 1+ restarts.
  
  For each example, this attack evaluates each base attack with N restarts and
  take the one with the highest loss.
class_docstr_tok: ["Composite","Attack","class","with","1+","base","attacks","and","1+","restarts",".","For","each","example",",","this","attack","evaluates","each","base","attack","with","N","restarts","and","take","the","one","with","the","highest","loss","."]
docstr: See base class.
docstr_tok: ["See","base","class","."]
code: def attack(self, x, y, model, loss, random_start=False):
      """See base class."""
      batch_shape = [x.shape[0]] + [1] * (x.shape.rank - 1)
      adv_x = x
      adv_loss = tf.zeros(batch_shape)
      for attack in self.attacks:
          for _ in range(self.restart):
              adv_x2 = attack.attack(x, y, model, loss, random_start)
              adv_loss2 = tf.reshape(
                  loss(y, model(adv_x2)), batch_shape
              )
              comparison = adv_loss < adv_loss2
              adv_x = tf.where(comparison, adv_x2, adv_x)
              adv_loss = tf.where(comparison, adv_loss2, adv_loss)
      return adv_x
  
imports: from absl import logging
  import gin
  import neural_structured_learning
  from multi_representation_adversary.cleverhans_adapter import sparse_l1_descent
  from multi_representation_adversary.cleverhans_adapter import utils_tf
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 2 for calling the UnionAttack obj's underlying member method code with example usage: obj.attack(x, y, model, loss, random_start) and returns: adv_x