class_docstr: This loss extends the SwAV loss proposed in paper https://arxiv.org/abs/2006.09882
  by Caron et al. The loss combines the benefits of using the SwAV approach
  with the momentum encoder as used in MoCo.
  
  Config params:
      momentum (float):               for the momentum encoder
      momentum_eval_mode_iter_start (int): from what iteration should the momentum encoder
                                      network be in eval mode
      embedding_dim (int):            the projection head output dimension
      temperature (float):            temperature to be applied to the logits
      use_double_precision (bool):    whether to use double precision for the loss.
                                      This could be a good idea to avoid NaNs.
      normalize_last_layer (bool):    whether to normalize the last layer
      num_iters (int):                number of sinkhorn algorithm iterations to make
      epsilon (float):                see the paper for details
      num_crops (int):                number of crops used
      crops_for_assign (List[int]):   what crops to use for assignment
      num_prototypes (List[int]):     number of prototypes
      queue:
          queue_length (int):         number of features to store and used in the scores
          start_iter (int):           when to start using the queue for the scores
          local_queue_length (int):   length of queue per gpu
class_docstr_tok: ["This","loss","extends","the","SwAV","loss","proposed","in","paper","https",":","\/\/arxiv.org\/abs\/2006.09882","by","Caron","et","al",".","The","loss","combines","the","benefits","of","using","the","SwAV","approach","with","the","momentum","encoder","as","used","in","MoCo",".","Config","params",":","momentum","(","float",")",":","for","the","momentum","encoder","momentum_eval_mode_iter_start","(","int",")",":","from","what","iteration","should","the","momentum","encoder","network","be","in","eval","mode","embedding_dim","(","int",")",":","the","projection","head","output","dimension","temperature","(","float",")",":","temperature","to","be","applied","to","the","logits","use_double_precision","(","bool",")",":","whether","to","use","double","precision","for","the","loss",".","This","could","be","a","good","idea","to","avoid","NaNs",".","normalize_last_layer","(","bool",")",":","whether","to","normalize","the","last","layer","num_iters","(","int",")",":","number","of","sinkhorn","algorithm","iterations","to","make","epsilon","(","float",")",":","see","the","paper","for","details","num_crops","(","int",")",":","number","of","crops","used","crops_for_assign","(","List","[","int","]",")",":","what","crops","to","use","for","assignment","num_prototypes","(","List","[","int","]",")",":","number","of","prototypes","queue",":","queue_length","(","int",")",":","number","of","features","to","store","and","used","in","the","scores","start_iter","(","int",")",":","when","to","start","using","the","queue","for","the","scores","local_queue_length","(","int",")",":","length","of","queue","per","gpu"]
code: def __init__(self, loss_config: AttrDict):
      super().__init__()
      self.loss_config = loss_config
  
      self.momentum_encoder = None
      self.checkpoint = None
      self.momentum_scores = None
      self.momentum_embeddings = None
      self.is_distributed = is_distributed_training_run()
      self.use_gpu = get_cuda_device_index() > -1
      self.softmax = nn.Softmax(dim=1)
  
      # keep track of number of iterations
      self.register_buffer("num_iteration", torch.zeros(1, dtype=int))
  
      # for queue
      self.use_queue = False
      if self.loss_config.queue.local_queue_length > 0:
          self.initialize_queue()
  
imports: import logging
  import math
  import pprint
  import numpy
  import torch
  from classy_vision.generic.distributed_util import all_reduce_sum, get_cuda_device_index, get_world_size, is_distributed_training_run
  from classy_vision.losses import ClassyLoss, register_loss
  from torch import nn
  from vissl.config import AttrDict
label_desc: Use image node_id 1 to create a new SwAVMomentumLoss object from inherited base classes: ClassyLoss with example: obj = SwAVMomentumLoss(loss_config)