docstr: Helper method to choose a loss class for the model based on the type
  of model, whether it has label or not and the number of sentences per example.
  
  Args:
      label: The label type, None should be passed if there is no label.
      number_of_sentences: number of sentences (two or three normally).
docstr_tok: ["Helper","method","to","choose","a","loss","class","for","the","model","based","on","the","type","of","model",",","whether","it","has","label","or","not","and","the","number","of","sentences","per","example",".","Args",":","label",":","The","label","type",",","None","should","be","passed","if","there","is","no","label",".","number_of_sentences",":","number","of","sentences","(","two","or","three","normally",")","."]
code: def _set_loss_cls(
      self, label: Optional[Union[int, float]], number_of_sentences: int
  ) -> None:
      """
      Helper method to choose a loss class for the model based on the type
      of model, whether it has label or not and the number of sentences per example.
  
      Args:
          label: The label type, None should be passed if there is no label.
          number_of_sentences: number of sentences (two or three normally).
      """
      if label:
          if number_of_sentences == 2:
              if isinstance(label, int):
                  from sentence_transformers.losses import (
                      ContrastiveLoss,
                  )
  
                  self._loss_cls = ContrastiveLoss
              else:
                  from sentence_transformers.losses import (
                      CosineSimilarityLoss,
                  )
  
                  self._loss_cls = CosineSimilarityLoss
  
          else:
              if isinstance(label, int):
                  from sentence_transformers.losses import (
                      BatchHardTripletLoss,
                  )
  
                  self._loss_cls = BatchHardTripletLoss
              else:
                  from sentence_transformers.losses import (
                      BatchAllTripletLoss,
                  )
  
                  self._loss_cls = BatchAllTripletLoss
                  from sentence_transformers.datasets import (
                      SentenceLabelDataset,
                  )
  
                  self.data_kwargs[
                      "dataset_type"
                  ] = SentenceLabelDataset
  
      else:
          if number_of_sentences == 3:
              from sentence_transformers.losses import TripletLoss
  
              self._loss_cls = TripletLoss
          else:
              from sentence_transformers.losses import (
                  MultipleNegativesRankingLoss,
              )
  
              self._loss_cls = MultipleNegativesRankingLoss
  
file_path: argilla/src/argilla/client/feedback/training/frameworks/sentence_transformers.py
imports: import logging
  from typing import TYPE_CHECKING, List, Optional, Tuple, Union
  from argilla.client.feedback.training.base import ArgillaTrainerSkeleton
  from argilla.client.feedback.training.schemas.base import TrainingTaskForSentenceSimilarity
  from argilla.training.utils import filter_allowed_args, get_default_args
  from argilla.utils.dependency import require_dependencies
label_desc: Use image node_id 3 for calling the ArgillaSentenceTransformersTrainer obj's underlying member method code with example usage: obj._set_loss_cls(label, number_of_sentences) without return types