code: def create_adv_by_name(
      model, x, attack_type, sess, dataset, y=None, **kwargs
  ):
      """
      Creates the symbolic graph of an adversarial example given the name of
      an attack. Simplifies creating the symbolic graph of an attack by defining
      dataset-specific parameters.
      Dataset-specific default parameters are used unless a different value is
      given in kwargs.
  
      :param model: an object of Model class
      :param x: Symbolic input to the attack.
      :param attack_type: A string that is the name of an attack.
      :param sess: Tensorflow session.
      :param dataset: The name of the dataset as a string to use for default
                     params.
      :param y: (optional) a symbolic variable for the labels.
      :param kwargs: (optional) additional parameters to be passed to the attack.
      """
      # TODO: black box attacks
      attack_names = {
          "FGSM": FastGradientMethod,
          "MadryEtAl": MadryEtAl,
          "MadryEtAl_y": MadryEtAl,
          "MadryEtAl_multigpu": MadryEtAlMultiGPU,
          "MadryEtAl_y_multigpu": MadryEtAlMultiGPU,
      }
  
      if attack_type not in attack_names:
          raise Exception("Attack %s not defined." % attack_type)
  
      attack_params_shared = {
          "mnist": {
              "eps": 0.3,
              "eps_iter": 0.01,
              "clip_min": 0.0,
              "clip_max": 1.0,
              "nb_iter": 40,
          },
          "cifar10": {
              "eps": 8.0 / 255,
              "eps_iter": 0.01,
              "clip_min": 0.0,
              "clip_max": 1.0,
              "nb_iter": 20,
          },
      }
  
      with tf.variable_scope(attack_type):
          attack_class = attack_names[attack_type]
          attack = attack_class(model, sess=sess)
  
          # Extract feedable and structural keyword arguments from kwargs
          fd_kwargs = (
              attack.feedable_kwargs.keys() + attack.structural_kwargs
          )
          params = attack_params_shared[dataset].copy()
          params.update(
              {k: v for k, v in kwargs.items() if v is not None}
          )
          params = {k: v for k, v in params.items() if k in fd_kwargs}
  
          if "_y" in attack_type:
              params["y"] = y
          logging.info(params)
          adv_x = attack.generate(x, **params)
  
      return adv_x
  
file_path: cleverhans/cleverhans_v3.1.0/examples/multigpu_advtrain/evaluator.py
imports: import logging
  import tensorflow
  from cleverhans.utils_tf import model_eval
  from cleverhans.attacks import FastGradientMethod
  from cleverhans.attacks import MadryEtAl
  from attacks_multigpu import MadryEtAlMultiGPU
label_desc: Use image node_id 1 for calling a global function with example usage: create_adv_by_name(model, x, attack_type, sess, dataset, y) and returns: adv_x