CosineEmbeddingLoss
class torch.nn.CosineEmbeddingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')
Creates a criterion that measures the loss given input tensors x_1,
   x_2 and a Tensor label y with values 1 or -1. This is used for
   measuring whether two inputs are similar or dissimilar, using the
   cosine similarity, and is typically used for learning nonlinear
   embeddings or semi-supervised learning.
The loss function for each sample is:
  \text{loss}(x, y) = \begin{cases} 1 - \cos(x_1, x_2), & \text{if
  } y = 1 \\ \max(0, \cos(x_1, x_2) - \text{margin}), & \text{if }
  y = -1 \end{cases}

Parameters:
      * margin (float, optional) -- Should be a number from
        -1 to 1, 0 to 0.5 is suggested. If "margin" is missing, the
        default value is 0.
  * **size_average** (*bool**, **optional*) -- Deprecated (see
    "reduction"). By default, the losses are averaged over each
