def METHOD_NAME(self, sentence_features: Iterable[Dict[str, Tensor]], labels: Tensor):
    reps = [self.model(sentence_feature)['sentence_embedding'] for sentence_feature in sentence_features]
    embeddings_a, embeddings_b = reps
    cos_scores = util.pytorch_cos_sim(embeddings_a, embeddings_b)
    positive_scores = torch.diagonal(cos_scores)
    negative_scores = cos_scores - (2*torch.eye(*cos_scores.shape, device=cos_scores.device))  # Remove positive scores along the diagonal
    negatives_max, _ = torch.max(negative_scores, dim=1)
    losses = F.relu(self.positive_margin - positive_scores) + F.relu(negatives_max - self.negative_margin)
    return losses.mean()