class_docstr: Implementation of the loss function from MSN [0].
  
  Code inspired by [1].
  
  - [0]: Masked Siamese Networks, 2022, https://arxiv.org/abs/2204.07141
  - [1]: https://github.com/facebookresearch/msn
  
  Attributes:
      temperature:
          Similarities between anchors and targets are scaled by the inverse of
          the temperature. Must be in (0, inf).
      sinkhorn_iterations:
          Number of sinkhorn normalization iterations on the targets.
      regularization_weight:
          Weight factor lambda by which the regularization loss is scaled. Set to 0
          to disable regularization.
      me_max_weight:
          Deprecated, use `regularization_weight` instead. Takes precendence over
          `regularization_weight` if not None. Weight factor lambda by which the mean
          entropy maximization regularization loss is scaled. Set to 0 to disable
          mean entropy maximization reguliarization.
      gather_distributed:
          If True, then target probabilities are gathered from all GPUs.
  
   Examples:
  
      >>> # initialize loss function
      >>> loss_fn = MSNLoss()
      >>>
      >>> # generate anchors and targets of images
      >>> anchors = transforms(images)
      >>> targets = transforms(images)
      >>>
      >>> # feed through MSN model
      >>> anchors_out = model(anchors)
      >>> targets_out = model.target(targets)
      >>>
      >>> # calculate loss
      >>> loss = loss_fn(anchors_out, targets_out, prototypes=model.prototypes)
docstr: Calculates mean entropy regularization loss.
docstr_tok: ["Calculates","mean","entropy","regularization","loss","."]
code: def regularization_loss(self, mean_anchor_probs: Tensor) -> Tensor:
      """Calculates mean entropy regularization loss."""
      loss = -torch.sum(
          torch.log(mean_anchor_probs ** (-mean_anchor_probs))
      )
      loss += math.log(float(len(mean_anchor_probs)))
      return loss
  
file_path: lightly/lightly/loss/msn_loss.py
imports: import math
  import warnings
  from typing import Union
  import torch
  import torch.distributed
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
label_desc: Use image node_id 3 for calling the MSNLoss obj's underlying member method code with example usage: obj.regularization_loss(mean_anchor_probs) and returns: loss