import tensorflow as tf

            grads_and_vars_not_none = [(g, v) for (g, v) in grads_and_vars if g is not None]
            grads = [g for (g, v) in grads_and_vars_not_none]
            variables = [v for (g, v) in grads_and_vars_not_none]

            #print_ops = [tf.print("loss=", self.loss)] + [tf.print("norms_g", tf.norm(g)) for g in grads] + [tf.print("g", g) for g in grads] + [tf.print("p", self.prob)] + [tf.print("invFisher", self.invFisher)] + [tf.print("invA", self.invA)] + [tf.print("invB", self.invB)]

            #print_ops = [tf.print("partA =", self.partA, summarize=-1), tf.print("partB =", self.partB, summarize=-1), tf.print("prob_sliced =", self.prob_sliced, summarize=-1), tf.print("natural_gradient_theta =", self.natural_gradient_loss_theta, summarize=-1), tf.print("euclidean gradient =", self.euclidean_gradient, summarize=-1), tf.print("TA =", self.TA, summarize=-1), tf.print("Tup =", self.Tup, summarize=-1) , tf.print("Tdown =", self.Tdown, summarize=-1) , tf.print("TB =", self.TB, summarize=-1)] + [tf.print("norms_g", tf.norm(g), summarize=-1) for g in grads]
            #with tf.control_dependencies(print_ops):
            clip_value = clipping_kwargs["value"]
            clipped_grads, global_norm = tf.clip_by_global_norm(grads, clip_value)
            clipped_grads_and_vars = [(clipped_grads[i], variables[i]) for i in range(len(grads))]

        elif clipping_method == "clip_by_norm":

            grads_and_vars_not_none = [(g, v) for (g, v) in grads_and_vars if g is not None]

            grads = [g for (g, v) in grads_and_vars_not_none]
            variables = [v for (g, v) in grads_and_vars_not_none]
