class_docstr: Calculates the pn loss (a variant of triplet loss) between anchor, positive and negative
  examples in a triplet based on cosine distance.
class_docstr_tok: ["Calculates","the","pn","loss","(","a","variant","of","triplet","loss",")","between","anchor",",","positive","and","negative","examples","in","a","triplet","based","on","cosine","distance","."]
code: def __call__(self, y_true, y_pred):
      anchor, positive, negative = tf.unstack(y_pred)
  
      anchor_positive_distance = cosine_distance(anchor, positive)
      anchor_negative_distance = cosine_distance(anchor, negative)
      positive_negative_distance = cosine_distance(positive, negative)
  
      stacked_an_pn_distance = [
          anchor_negative_distance,
          positive_negative_distance,
      ]
  
      return K.mean(
          K.maximum(
              anchor_positive_distance
              - stacked_an_pn_distance
              + self.margin,
              0,
          )
      )
  
imports: import functools
  from tensorflow.keras import backend
  import tensorflow
  from tensorflow import keras
  import numpy
  from .distances import euclidean_distance, manhattan_distance, chebyshev_distance, cosine_distance
label_desc: Use image node_id 2 for calling the CosinePnLoss obj's underlying member method code with example usage: obj.__call__(y_true, y_pred) and returns: K