import tensorflow as tf

        logit, = op.inputs
        if FLAGS.RCE_train==True:
            logit = -logit
        if tsne_logits==True:
            return logit,model.t_SNE_logits
        return logit

def adv_craft_func(hps, images, method, eps=0.01,RCE_train=False, target_labels=None):
    if method=='fgsm':
        print('Attacking method is fgsm')
        adversarial_sample = attacks.fgsm.fgsm(models, images, hps, RCE_train,
                                               eps=eps, epochs=1, clip_min=-0.5, clip_max=0.5)
    elif method=='random':
        print('Attacking method is random')
        adversarial_sample = tf.clip_by_value(images + tf.random_uniform((hps.batch_size,image_size,image_size,num_channel),
                                                        minval=-eps, maxval=eps), clip_value_min=-0.5, clip_value_max=0.5)
    elif method=='bim':
        print('Attacking method is bim')
        adversarial_sample = attacks.fgsm.fgsm(models, images, hps, RCE_train,
                                               eps=eps/10, epochs=10, clip_min=-0.5, clip_max=0.5)
    elif method=='tgsm':
        print('Attacking method is tgsm')
        adversarial_sample = attacks.tgsm.tgsm(models, images, hps, RCE_train, y=None,
                                               eps=eps/10, epochs=10, clip_min=-0.5, clip_max=0.5)

    elif method=='jsma':
        print('Attacking method is jsma')
        if target_labels==None:
