class_docstr: Implementation of the Barlow Twins Loss from Barlow Twins[0] paper.
  This code specifically implements the Figure Algorithm 1 from [0].
  
  [0] Zbontar,J. et.al, 2021, Barlow Twins... https://arxiv.org/abs/2103.03230
  
      Examples:
  
      >>> # initialize loss function
      >>> loss_fn = BarlowTwinsLoss()
      >>>
      >>> # generate two random transforms of images
      >>> t0 = transforms(images)
      >>> t1 = transforms(images)
      >>>
      >>> # feed through SimSiam model
      >>> out0, out1 = model(t0, t1)
      >>>
      >>> # calculate loss
      >>> loss = loss_fn(out0, out1)
docstr: Lambda param configuration with default value like in [0]
  
  Args:
      lambda_param:
          Parameter for importance of redundancy reduction term.
          Defaults to 5e-3 [0].
      gather_distributed:
          If True then the cross-correlation matrices from all gpus are
          gathered and summed before the loss calculation.
docstr_tok: ["Lambda","param","configuration","with","default","value","like","in","[","0","]","Args",":","lambda_param",":","Parameter","for","importance","of","redundancy","reduction","term",".","Defaults","to","5e-3","[","0","]",".","gather_distributed",":","If","True","then","the","cross-correlation","matrices","from","all","gpus","are","gathered","and","summed","before","the","loss","calculation","."]
code: def __init__(
      self, lambda_param: float = 5e-3, gather_distributed: bool = False
  ):
      """Lambda param configuration with default value like in [0]
  
      Args:
          lambda_param:
              Parameter for importance of redundancy reduction term.
              Defaults to 5e-3 [0].
          gather_distributed:
              If True then the cross-correlation matrices from all gpus are
              gathered and summed before the loss calculation.
      """
      super(BarlowTwinsLoss, self).__init__()
      self.lambda_param = lambda_param
      self.gather_distributed = gather_distributed
  
      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."
          )
  
file_path: lightly/lightly/loss/barlow_twins_loss.py
imports: from typing import Tuple
  import torch
  import torch.distributed
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new BarlowTwinsLoss object from inherited base classes: torch.nn with example: obj = BarlowTwinsLoss(lambda_param, gather_distributed)