code: def contrastive_loss(y_pred, y_true, margin=1.0):
      """Contrastive Loss.
  
      Computes the constrative loss between y_pred (logits) and
      y_true (labels).
  
      http://yann.lecun.com/exdb/publis/pdf/chopra-05.pdf
      Sumit Chopra, Raia Hadsell and Yann LeCun (2005).
      Learning a Similarity Metric Discriminatively, with Application to Face Verification.
  
      Arguments:
          y_pred: `Tensor`. Predicted values.
          y_true: `Tensor`. Targets (labels).
          margin: . A self-set parameters that indicate the distance between the expected different identity features. Defaults 1.
      """
      with tf.name_scope("ContrastiveLoss"):
          dis1 = y_true * tf.square(y_pred)
          dis2 = (1 - y_true) * tf.square(
              tf.maximum((margin - y_pred), 0)
          )
          return tf.reduce_sum(dis1 + dis2) / 2.0
  
file_path: tflearn/tflearn/objectives.py
imports: from __future__ import division, print_function, absolute_import
  import tensorflow.compat.v1
  from .config import _EPSILON, _FLOATX
  from .utils import get_from_module
label_desc: Use image node_id 10 for calling a global function with example usage: contrastive_loss(y_pred, y_true, margin) and returns: unknown