class_docstr: Implementation of the VICReg loss [0].
  
  This implementation is based on the code published by the authors [1].
  
  - [0] VICReg, 2022, https://arxiv.org/abs/2105.04906
  - [1] https://github.com/facebookresearch/vicreg/
  
  Attributes:
      lambda_param:
          Scaling coefficient for the invariance term of the loss.
      mu_param:
          Scaling coefficient for the variance term of the loss.
      nu_param:
          Scaling coefficient for the covariance term of the loss.
      gather_distributed:
          If True then the cross-correlation matrices from all gpus are gathered and
          summed before the loss calculation.
      eps:
          Epsilon for numerical stability.
  
  Examples:
  
      >>> # initialize loss function
      >>> loss_fn = VICRegLoss()
      >>>
      >>> # generate two random transforms of images
      >>> t0 = transforms(images)
      >>> t1 = transforms(images)
      >>>
      >>> # feed through model
      >>> out0, out1 = model(t0, t1)
      >>>
      >>> # calculate loss
      >>> loss = loss_fn(out0, out1)
class_docstr_tok: ["Implementation","of","the","VICReg","loss","[","0","]",".","This","implementation","is","based","on","the","code","published","by","the","authors","[","1","]",".","-","[","0","]","VICReg",",","2022",",","https",":","\/\/arxiv.org\/abs\/2105.04906","-","[","1","]","https",":","\/\/github.com\/facebookresearch\/vicreg\/","Attributes",":","lambda_param",":","Scaling","coefficient","for","the","invariance","term","of","the","loss",".","mu_param",":","Scaling","coefficient","for","the","variance","term","of","the","loss",".","nu_param",":","Scaling","coefficient","for","the","covariance","term","of","the","loss",".","gather_distributed",":","If","True","then","the","cross-correlation","matrices","from","all","gpus","are","gathered","and","summed","before","the","loss","calculation",".","eps",":","Epsilon","for","numerical","stability",".","Examples",":",">",">",">","#","initialize","loss","function",">",">",">","loss_fn","=","VICRegLoss","(",")",">",">",">",">",">",">","#","generate","two","random","transforms","of","images",">",">",">","t0","=","transforms","(","images",")",">",">",">","t1","=","transforms","(","images",")",">",">",">",">",">",">","#","feed","through","model",">",">",">","out0",",","out1","=","model","(","t0",",","t1",")",">",">",">",">",">",">","#","calculate","loss",">",">",">","loss","=","loss_fn","(","out0",",","out1",")"]
code: def __init__(
      self,
      lambda_param: float = 25.0,
      mu_param: float = 25.0,
      nu_param: float = 1.0,
      gather_distributed: bool = False,
      eps=0.0001,
  ):
      super(VICRegLoss, self).__init__()
      if gather_distributed and not dist.is_available():
          raise ValueError(
              "gather_distributed is True but torch.distributed is not available. "
              "Please set gather_distributed=False or install a torch version with "
              "distributed support."
          )
  
      self.lambda_param = lambda_param
      self.mu_param = mu_param
      self.nu_param = nu_param
      self.gather_distributed = gather_distributed
      self.eps = eps
  
file_path: lightly/lightly/loss/vicreg_loss.py
imports: import torch
  import torch.distributed
  import torch.nn.functional
  from torch import Tensor
  from lightly.utils.dist import gather
label_desc: Use image node_id 1 to create a new VICRegLoss object from inherited base classes: torch.nn with example: obj = VICRegLoss(lambda_param, mu_param, nu_param, gather_distributed, eps)