def __init__(
        self,
        temperature: float = 0.1,
        weight_fn: Optional[Callable[[Tensor, Tensor], Tensor]] = None,
        gather_distributed: bool = False,
    ):
        """Initialzes the DCLoss module.

        Args:
            temperature:
                Similarities are scaled by inverse temperature.
            weight_fn:
                 Weighting function `w` from the paper. Scales the loss between the
                positive views (views from the same image). No weighting is performed
                if weight_fn is None. The function must take the two input tensors
                passed to the forward call as input and return a weight tensor. The
                returned weight tensor must have the same length as the input tensors.
            gather_distributed:
                If True, negatives from all GPUs are gathered before the
                loss calculation.

        Raises:
            ValuesError: If gather_distributed is True but torch.distributed is not available.
        """
        super().__init__()
        self.temperature = temperature
        self.weight_fn = weight_fn
        self.gather_distributed = gather_distributed

        # Check if distributed gathering is enabled but torch.distributed is not available
        if gather_distributed and not torch_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."
            )
Initialzes the DCLoss module.

        Args:
            temperature:
                Similarities are scaled by inverse temperature.
            weight_fn:
                 Weighting function `w` from the paper. Scales the loss between the
                positive views (views from the same image). No weighting is performed
                if weight_fn is None. The function must take the two input tensors
                passed to the forward call as input and return a weight tensor. The
                returned weight tensor must have the same length as the input tensors.
            gather_distributed:
                If True, negatives from all GPUs are gathered before the
                loss calculation.

        Raises:
            ValuesError: If gather_distributed is True but torch.distributed is not available.
        
lightly/loss/dcl_loss.py