class_docstr: Compute contrastive loss
  Args:
      margin (int): margin
      max_violation (int): image feature dimension
class_docstr_tok: ["Compute","contrastive","loss","Args",":","margin","(","int",")",":","margin","max_violation","(","int",")",":","image","feature","dimension"]
code: def forward(self, im, s, return_similarity_mat=False):
      # compute image-sentence score matrix
      scores = self.sim(im, s)
      loss = self.compute_contrastive_loss(scores)
      if return_similarity_mat:
          return loss, scores
      else:
          return loss
  
file_path: towhee/towhee/models/mcprop/loss.py
imports: import torch
  from torch import nn
label_desc: Use image node_id 2 for calling the ContrastiveLoss obj's underlying member method code with example usage: obj.forward(im, s, return_similarity_mat) and returns: loss,  scores, loss