class_docstr: Implementation of the loss described in 'Emerging Properties in
  Self-Supervised Vision Transformers'. [0]
  
  This implementation follows the code published by the authors. [1]
  It supports global and local image crops. A linear warmup schedule for the
  teacher temperature is implemented to stabilize training at the beginning.
  Centering is applied to the teacher output to avoid model collapse.
  
  - [0]: DINO, 2021, https://arxiv.org/abs/2104.14294
  - [1]: https://github.com/facebookresearch/dino
  
  Attributes:
      output_dim:
          Dimension of the model output.
      warmup_teacher_temp:
          Initial value of the teacher temperature. Should be decreased if the
          training loss does not decrease.
      teacher_temp:
          Final value of the teacher temperature after linear warmup. Values
          above 0.07 result in unstable behavior in most cases. Can be
          slightly increased to improve performance during finetuning.
      warmup_teacher_temp_epochs:
          Number of epochs for the teacher temperature warmup.
      student_temp:
          Temperature of the student.
      center_momentum:
          Momentum term for the center calculation.
  
  Examples:
  
      >>> # initialize loss function
      >>> loss_fn = DINOLoss(128)
      >>>
      >>> # generate a view of the images with a random transform
      >>> view = transform(images)
      >>>
      >>> # embed the view with a student and teacher model
      >>> teacher_out = teacher(view)
      >>> student_out = student(view)
      >>>
      >>> # calculate loss
      >>> loss = loss_fn([teacher_out], [student_out], epoch=0)
docstr: Moving average update of the center used for the teacher output.
  
  Args:
      teacher_out:
          Stacked output from the teacher model.
docstr_tok: ["Moving","average","update","of","the","center","used","for","the","teacher","output",".","Args",":","teacher_out",":","Stacked","output","from","the","teacher","model","."]
code: def update_center(self, teacher_out: torch.Tensor) -> None:
      """Moving average update of the center used for the teacher output.
  
      Args:
          teacher_out:
              Stacked output from the teacher model.
  
      """
      batch_center = torch.mean(teacher_out, dim=(0, 1), keepdim=True)
      if dist.is_available() and dist.is_initialized():
          dist.all_reduce(batch_center)
          batch_center = batch_center / dist.get_world_size()
  
      # ema update
      self.center = (
          self.center * self.center_momentum
          + batch_center * (1 - self.center_momentum)
      )
  
file_path: lightly/lightly/loss/dino_loss.py
imports: from typing import List
  import torch
  import torch.distributed
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 3 for calling the DINOLoss obj's underlying member method code with example usage: obj.update_center(teacher_out) without return types