class_docstr: Contrastive loss. Expects as input two texts and a label of either 0 or 1. If the label == 1, then the distance between the
  two embeddings is reduced. If the label == 0, then the distance between the embeddings is increased.
  
  Further information: http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf
  
  :param model: SentenceTransformer model
  :param distance_metric: Function that returns a distance between two embeddings. The class SiameseDistanceMetric contains pre-defined metrices that can be used
  :param margin: Negative samples (label == 0) should have a distance of at least the margin value.
  :param size_average: Average by the size of the mini-batch.
  
  Example::
  
      from sentence_transformers import SentenceTransformer, LoggingHandler, losses, InputExample
      from torch.utils.data import DataLoader
  
      model = SentenceTransformer('all-MiniLM-L6-v2')
      train_examples = [
          InputExample(texts=['This is a positive pair', 'Where the distance will be minimized'], label=1),
          InputExample(texts=['This is a negative pair', 'Their distance will be increased'], label=0)]
  
      train_dataloader = DataLoader(train_examples, shuffle=True, batch_size=2)
      train_loss = losses.ContrastiveLoss(model=model)
  
      model.fit([(train_dataloader, train_loss)], show_progress_bar=True)
code: def get_config_dict(self):
      distance_metric_name = self.distance_metric.__name__
      for name, value in vars(SiameseDistanceMetric).items():
          if value == self.distance_metric:
              distance_metric_name = "SiameseDistanceMetric.{}".format(
                  name
              )
              break
  
      return {
          "distance_metric": distance_metric_name,
          "margin": self.margin,
          "size_average": self.size_average,
      }
  
file_path: sentence-transformers/sentence_transformers/losses/ContrastiveLoss.py
imports: from enum import Enum
  from typing import Iterable, Dict
  import torch.nn.functional
  from torch import nn, Tensor
  from sentence_transformers.SentenceTransformer import SentenceTransformer
label_desc: Use image node_id 2 for calling the ContrastiveLoss obj's underlying member method code with example usage: obj.get_config_dict() and returns: dict