code: def clip_gradient(value, clip_value):
      if not hasattr(clip_gradient, "added_gradients"):
          clip_gradient.added_gradients = set()
  
      session = tensorflow_session()
      graph = session.graph
      operation_name = "ClipGradient-" + str(clip_value)
  
      if operation_name not in clip_gradient.added_gradients:
          # Make sure that we won't create the same operation twice.
          # Otherwise tensorflow will trigger an exception.
          @tf.RegisterGradient(operation_name)
          def clip_gradient_grad(op, grad):
              return tf.clip_by_value(grad, -clip_value, clip_value)
  
          clip_gradient.added_gradients.add(operation_name)
  
      with graph.gradient_override_map({"Identity": operation_name}):
          return tf.identity(value)
  
imports: import types
  import tensorflow
  from neupy import init
  from neupy.utils import tensorflow_session
  from neupy.exceptions import LayerConnectionError
  from neupy.core.properties import IntProperty, Property, NumberProperty, ParameterProperty
  from .base import BaseLayer
label_desc: Use image node_id 1 for calling a global function with example usage: clip_gradient(value, clip_value) and returns: tf, tf