HingeEmbeddingLoss
class torch.nn.HingeEmbeddingLoss(margin=1.0, size_average=None, reduce=None, reduction='mean')
Measures the loss given an input tensor x and a labels tensor y
   (containing 1 or -1). This is usually used for measuring whether
   two inputs are similar or dissimilar, e.g. using the L1 pairwise
   distance as x, and is typically used for learning nonlinear
   embeddings or semi-supervised learning.
The loss function for n-th sample in the mini-batch is
  l_n = \begin{cases}     x_n, & \text{if}\; y_n = 1,\\     \max
  \{0, \Delta - x_n\}, & \text{if}\; y_n = -1, \end{cases}

and the total loss functions is
  \ell(x, y) = \begin{cases}     \operatorname{mean}(L), &
  \text{if reduction} = \text{`mean';}\\
  \operatorname{sum}(L),  & \text{if reduction} = \text{`sum'.}
  \end{cases}

where L = {l_1,\dots,l_N}^\top.
Parameters:
      * margin (float, optional) -- Has a default value of
        1.