code: def contrastive_loss(label, feature1, feature2):
      margin = 1.0
      eucd = tf.sqrt(
          tf.reduce_sum(tf.square(feature1 - feature2), axis=1)
      )
      return tf.reduce_mean(
          label * tf.square(eucd)
          + (1 - label) * tf.square(tf.maximum(margin - eucd, 0))
      )
  
file_path: TensorLayer/examples/basic_tutorials/tutorial_mnist_siamese.py
imports: import random
  import time
  import numpy
  import tensorflow
  import tensorlayer
  from tensorlayer.layers import Dense, Dropout, Flatten, Input
  from tensorlayer.models import Model
label_desc: Use image node_id 1 for calling a global function with example usage: contrastive_loss(label, feature1, feature2) and returns: tf