'Generate symbolic graph for adversarial examples and return.
:param x: The model\'s symbolic inputs.
:param theta: (optional float) Perturbation introduced to modified
components (can be positive or negative)
:param gamma: (optional float) Maximum percentage of perturbed features
:param nb_classes: (optional int) Number of model output classes
:param clip_min: (optional float) Minimum component value for clipping
:param clip_max: (optional float) Maximum component value for clipping
:param y_target: (optional) Target tensor if the attack is targeted'

def generate(self, x, **kwargs):

    import tensorflow as tf
    from .attacks_tf import jacobian_graph, jsma_batch
    assert self.parse_params(**kwargs)
    preds = self.model.get_probs(x)
    grads = jacobian_graph(preds, x, self.nb_classes)
    if (self.y_target is not None):
        def jsma_wrap(x_val, y_target):
            return jsma_batch(self.sess, x, preds, grads, x_val, self.theta, self.gamma, self.clip_min, self.clip_max, self.nb_classes, y_target=y_target)
        wrap = tf.py_func(jsma_wrap, [x, self.y_target], tf.float32)
    else:
        def jsma_wrap(x_val):
            return jsma_batch(self.sess, x, preds, grads, x_val, self.theta, self.gamma, self.clip_min, self.clip_max, self.nb_classes, y_target=None)
        wrap = tf.py_func(jsma_wrap, [x], tf.float32)
    return wrap
