class_docstr: Implementation of the loss function from PMSN [0] using a power law target
  distribution.
  
  - [0]: Prior Matching for Siamese Networks, 2022, https://arxiv.org/abs/2210.07277
  
  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.
      power_law_exponent:
          Exponent for power law distribution. Entry k of the distribution is
          proportional to (1 / k) ^ power_law_exponent, with k ranging from 1 to dim + 1.
      gather_distributed:
          If True, then target probabilities are gathered from all GPUs.
  
   Examples:
  
      >>> # initialize loss function
      >>> loss_fn = PMSNLoss()
      >>>
      >>> # generate anchors and targets of images
      >>> anchors = transforms(images)
      >>> targets = transforms(images)
      >>>
      >>> # feed through PMSN model
      >>> anchors_out = model(anchors)
      >>> targets_out = model.target(targets)
      >>>
      >>> # calculate loss
      >>> loss = loss_fn(anchors_out, targets_out, prototypes=model.prototypes)
docstr: Calculates regularization loss with a power law target distribution.
docstr_tok: ["Calculates","regularization","loss","with","a","power","law","target","distribution","."]
code: def regularization_loss(self, mean_anchor_probs: Tensor) -> Tensor:
      """Calculates regularization loss with a power law target distribution."""
      power_dist = _power_law_distribution(
          size=mean_anchor_probs.shape[0],
          exponent=self.power_law_exponent,
          device=mean_anchor_probs.device,
      )
      loss = F.kl_div(
          input=mean_anchor_probs.log(),
          target=power_dist,
          reduction="sum",
      )
      return loss
  
file_path: lightly/lightly/loss/pmsn_loss.py
imports: from typing import Callable
  import torch
  import torch.nn.functional
  from torch import Tensor
  from lightly.loss.msn_loss import MSNLoss
label_desc: Use image node_id 2 for calling the PMSNLoss obj's underlying member method code with example usage: obj.regularization_loss(mean_anchor_probs) and returns: loss