class_docstr: By inherting from `TestMadryEtAl`, the attack `MadryEtAlMultiGPU` can be
  tested against all tests of the base attack.
class_docstr_tok: ["By","inherting","from","`","TestMadryEtAl","`",",","the","attack","`","MadryEtAlMultiGPU","`","can","be","tested","against","all","tests","of","the","base","attack","."]
docstr: Compare the strength of the single GPU and multi-GPU implementations.
docstr_tok: ["Compare","the","strength","of","the","single","GPU","and","multi-GPU","implementations","."]
code: def test_single_vs_multi_gpu(self):
      """
      Compare the strength of the single GPU and multi-GPU implementations.
      """
      x_val = np.random.rand(100, 2)
      x_val = np.array(x_val, dtype=np.float32)
  
      def multi_attack(attack):
          flags = {
              "ngpu": 1,
              "eps": 1.0,
              "eps_iter": 0.01,
              "clip_min": 0.5,
              "clip_max": 0.7,
              "nb_iter": 2,
              "rand_init": True,
          }
  
          orig_labs = np.argmax(
              self.sess.run(self.model(x_val)), axis=1
          )
          new_labs_multi = orig_labs.copy()
          # Generate multiple adversarial examples
          for i in range(40):
              x_adv = attack.generate_np(x_val, **flags)
              new_labs = np.argmax(
                  self.sess.run(self.model(x_adv)), axis=1
              )
  
              # Examples for which we have not found adversarial examples
              indices = orig_labs == new_labs_multi
              new_labs_multi[indices] = new_labs[indices]
  
          return np.mean(orig_labs == new_labs_multi)
  
      acc_s = multi_attack(self.attack_single_gpu)
      acc_m = multi_attack(self.attack_multi_gpu)
  
      self.assertClose(acc_s, acc_m, atol=1e-2)
  
file_path: cleverhans/cleverhans_v3.1.0/examples/multigpu_advtrain/test_attack_multigpu.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import unittest
  import numpy
  import tensorflow
  from attacks_multigpu import MadryEtAlMultiGPU
  from model import MLPnGPU
  from model import LayernGPU
  import sys
  import os
  from test_attacks import TestMadryEtAl
label_desc: Use image node_id 2 for calling the TestMadryEtAlMultiGPU obj's underlying member method code with example usage: obj.test_single_vs_multi_gpu() and returns: np