class_docstr: This loss expects as input a batch consisting of pairs (a_1, p_1), (a_2, p_2)…, (a_n, p_n) where
      we assume that (a_i, p_i) are a positive pair and (a_i, p_j) for i!=j a negative pair.
      For each a_i, it uses all other p_j as negative samples, i.e., for a_i,
      we have 1 positive example (p_i) and n-1 negative examples (p_j).
      It then minimizes the negative log-likehood for softmax normalized scores.
      It can also support gather negatives across processes.
docstr: Parameters
  ----------
  local_loss
      Whether to compute the loss only for the current process's samples.
  gather_with_grad
      Whether to gather all features with gradients enabled.
  cache_labels
      Whether to cache labels for loss in next iterations.
  use_horovod
      Whether to use horovod.
docstr_tok: ["Parameters","--","--","--","--","--","local_loss","Whether","to","compute","the","loss","only","for","the","current","process","'s","samples",".","gather_with_grad","Whether","to","gather","all","features","with","gradients","enabled",".","cache_labels","Whether","to","cache","labels","for","loss","in","next","iterations",".","use_horovod","Whether","to","use","horovod","."]
code: def __init__(
      self,
      local_loss=False,
      gather_with_grad=False,
      cache_labels=False,
      use_horovod=False,
  ):
      """
      Parameters
      ----------
      local_loss
          Whether to compute the loss only for the current process's samples.
      gather_with_grad
          Whether to gather all features with gradients enabled.
      cache_labels
          Whether to cache labels for loss in next iterations.
      use_horovod
          Whether to use horovod.
      """
      super().__init__()
      self.local_loss = local_loss
      self.gather_with_grad = gather_with_grad
      self.cache_labels = cache_labels
      self.use_horovod = use_horovod
  
      # cache state
      self.prev_num_logits = 0
      self.labels = {}
  
imports: import logging
  from typing import Optional
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new MultiNegativesSoftmaxLoss object from inherited base classes: nn with example: obj = MultiNegativesSoftmaxLoss(local_loss, gather_with_grad, cache_labels, use_horovod)