class_docstr: This is the loss which was proposed in the "Momentum Contrast
  for Unsupervised Visual Representation Learning" paper, from Kaiming He et al.
  See http://arxiv.org/abs/1911.05722 for details
  and https://github.com/facebookresearch/moco for a reference implementation, reused here
  
  Config params:
      embedding_dim (int): head output output dimension
      queue_size (int): number of elements in queue
      momentum (float): encoder momentum value for the update
      temperature (float): temperature to use on the logits
class_docstr_tok: ["This","is","the","loss","which","was","proposed","in","the","``","Momentum","Contrast","for","Unsupervised","Visual","Representation","Learning","''","paper",",","from","Kaiming","He","et","al",".","See","http",":","\/\/arxiv.org\/abs\/1911.05722","for","details","and","https",":","\/\/github.com\/facebookresearch\/moco","for","a","reference","implementation",",","reused","here","Config","params",":","embedding_dim","(","int",")",":","head","output","output","dimension","queue_size","(","int",")",":","number","of","elements","in","queue","momentum","(","float",")",":","encoder","momentum","value","for","the","update","temperature","(","float",")",":","temperature","to","use","on","the","logits"]
docstr: Discard the oldest key from the MoCo queue, save the newest one,
  through a round-robin mechanism
docstr_tok: ["Discard","the","oldest","key","from","the","MoCo","queue",",","save","the","newest","one",",","through","a","round-robin","mechanism"]
code: def _dequeue_and_enqueue(self, key: torch.Tensor):
      """
      Discard the oldest key from the MoCo queue, save the newest one,
      through a round-robin mechanism
      """
  
      # gather keys before updating queue /!\ the queue is duplicated on all GPUs
      keys = concat_all_gather(key)
      batch_size = keys.shape[0]
  
      # for simplicity, removes the case where the batch overlaps with the end
      # of the queue
      assert self.loss_config.queue_size % batch_size == 0, (
          f"The queue size needs to be a multiple of the batch size. "
          f"Effective batch size: {batch_size}. Queue size:"
          f" {self.loss_config.queue_size}."
      )
  
      # replace the keys at ptr (dequeue and enqueue)
      ptr = int(self.queue_ptr)
      self.queue[:, ptr : ptr + batch_size] = keys.T
      ptr = (
          ptr + batch_size
      ) % self.loss_config.queue_size  # move pointer, round robin
  
      self.queue_ptr[0] = ptr
  
file_path: vissl/vissl/losses/moco_loss.py
imports: import logging
  import pprint
  from collections import namedtuple
  import torch
  from classy_vision.losses import ClassyLoss, register_loss
  from torch import nn
  from vissl.utils.misc import concat_all_gather
label_desc: Use image node_id 3 for calling the MoCoLoss obj's underlying member method code with example usage: obj._dequeue_and_enqueue(key) without return types