TripletMarginWithDistanceLoss
class torch.nn.TripletMarginWithDistanceLoss(*, distance_function=None, margin=1.0, swap=False, reduction='mean')
Creates a criterion that measures the triplet loss given input
   tensors a, p, and n (representing anchor, positive, and negative
   examples, respectively), and a nonnegative, real-valued function
   ("distance function") used to compute the relationship between the
   anchor and positive example ("positive distance") and the anchor
   and negative example ("negative distance").
The unreduced loss (i.e., with "reduction" set to "'none'") can be
   described as:
  \ell(a, p, n) = L = \{l_1,\dots,l_N\}^\top, \quad l_i = \max
  \{d(a_i, p_i) - d(a_i, n_i) + {\rm margin}, 0\}

where N is the batch size; d is a nonnegative, real-valued function
   quantifying the closeness of two tensors, referred to as the
   "distance_function"; and margin is a nonnegative margin