class_docstr: Implementation of the SwaV loss.
  
  Attributes:
      temperature:
          Temperature parameter used for cross entropy calculations.
      sinkhorn_iterations:
          Number of iterations of the sinkhorn algorithm.
      sinkhorn_epsilon:
          Temperature parameter used in the sinkhorn algorithm.
      sinkhorn_gather_distributed:
          If True then features from all gpus are gathered to calculate the
          soft codes in the sinkhorn algorithm.
docstr: Computes the SwaV loss for a set of high and low resolution outputs.
  
  Args:
      high_resolution_outputs:
          List of similarities of features and SwaV prototypes for the
          high resolution crops.
      low_resolution_outputs:
          List of similarities of features and SwaV prototypes for the
          low resolution crops.
      queue_outputs:
          List of similarities of features and SwaV prototypes for the
          queue of high resolution crops from previous batches.
  
  Returns:
      Swapping assignments between views loss (SwaV) as described in [0].
  
  [0]: SwaV, 2020, https://arxiv.org/abs/2006.09882
docstr_tok: ["Computes","the","SwaV","loss","for","a","set","of","high","and","low","resolution","outputs",".","Args",":","high_resolution_outputs",":","List","of","similarities","of","features","and","SwaV","prototypes","for","the","high","resolution","crops",".","low_resolution_outputs",":","List","of","similarities","of","features","and","SwaV","prototypes","for","the","low","resolution","crops",".","queue_outputs",":","List","of","similarities","of","features","and","SwaV","prototypes","for","the","queue","of","high","resolution","crops","from","previous","batches",".","Returns",":","Swapping","assignments","between","views","loss","(","SwaV",")","as","described","in","[","0","]",".","[","0","]",":","SwaV",",","2020",",","https",":","\/\/arxiv.org\/abs\/2006.09882"]
code: def forward(
      self,
      high_resolution_outputs: List[torch.Tensor],
      low_resolution_outputs: List[torch.Tensor],
      queue_outputs: List[torch.Tensor] = None,
  ):
      """Computes the SwaV loss for a set of high and low resolution outputs.
  
      Args:
          high_resolution_outputs:
              List of similarities of features and SwaV prototypes for the
              high resolution crops.
          low_resolution_outputs:
              List of similarities of features and SwaV prototypes for the
              low resolution crops.
          queue_outputs:
              List of similarities of features and SwaV prototypes for the
              queue of high resolution crops from previous batches.
  
      Returns:
          Swapping assignments between views loss (SwaV) as described in [0].
  
      [0]: SwaV, 2020, https://arxiv.org/abs/2006.09882
  
      """
      n_crops = len(high_resolution_outputs) + len(
          low_resolution_outputs
      )
  
      # multi-crop iterations
      loss = 0.0
      for i in range(len(high_resolution_outputs)):
          # compute codes of i-th high resolution crop
          with torch.no_grad():
              outputs = high_resolution_outputs[i].detach()
  
              # Append queue outputs
              if queue_outputs is not None:
                  outputs = torch.cat(
                      (outputs, queue_outputs[i].detach())
                  )
  
              # Compute the codes
              q = sinkhorn(
                  outputs,
                  iterations=self.sinkhorn_iterations,
                  epsilon=self.sinkhorn_epsilon,
                  gather_distributed=self.sinkhorn_gather_distributed,
              )
  
              # Drop queue similarities
              if queue_outputs is not None:
                  q = q[: len(high_resolution_outputs[i])]
  
          # compute subloss for each pair of crops
          subloss = 0.0
          for v in range(len(high_resolution_outputs)):
              if v != i:
                  subloss += self.subloss(high_resolution_outputs[v], q)
  
          for v in range(len(low_resolution_outputs)):
              subloss += self.subloss(low_resolution_outputs[v], q)
  
          loss += subloss / (n_crops - 1)
  
      return loss / len(high_resolution_outputs)
  
file_path: lightly/lightly/loss/swav_loss.py
imports: from typing import List
  import torch
  import torch.distributed
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 3 for calling the SwaVLoss obj's underlying member method code with example usage: obj.forward(high_resolution_outputs, low_resolution_outputs, queue_outputs) and returns: unknown