class_docstr: Computes the scores of the model embeddings against the `positive'
  and `negative' samples from the Memory Bank.
  This class does *NOT* compute the actual loss, just the scores,
  i.e., inner products followed by normalizations/exponentiation etc.
class_docstr_tok: ["Computes","the","scores","of","the","model","embeddings","against","the","`","positive'","and","`","negative","'","samples","from","the","Memory","Bank",".","This","class","does","*","NOT","*","compute","the","actual","loss",",","just","the","scores",",","i.e.",",","inner","products","followed","by","normalizations\/exponentiation","etc","."]
code: def update_memory(self, embedding, y):
      momentum = self.params[3].item()
      if (
          torch.distributed.is_available()
          and torch.distributed.is_initialized()
      ):
          # gather all embeddings.
          embedding_gathered = gather_from_all(embedding)
          y_gathered = gather_from_all(y)
      else:
          embedding_gathered = embedding
          y_gathered = y
  
      # update memory
      with torch.no_grad():
          # Assumption: memory_size >= y.max()
          assert y_gathered.max() < self.memory.shape[0], (
              f"Memory bank {self.memory.shape} is not sufficient "
              f"to hold index: {y_gathered.max()}"
          )
          l_pos = torch.index_select(
              self.memory, 0, y_gathered.view(-1)
          )
          l_pos.mul_(momentum)
          l_pos.add_(torch.mul(embedding_gathered, 1 - momentum))
          updated_l = nn.functional.normalize(l_pos, p=2, dim=1)
          self.memory.index_copy_(0, y_gathered, updated_l)
  
imports: import logging
  import math
  import pprint
  from typing import List, Union
  import numpy
  import torch
  from classy_vision.generic.distributed_util import all_reduce_mean, gather_from_all, get_rank
  from classy_vision.generic.util import is_pos_int
  from classy_vision.losses import ClassyLoss, register_loss
  from torch import nn
  from vissl.config import AttrDict
label_desc: Use image node_id 7 for calling the NCEAverage obj's underlying member method code with example usage: obj.update_memory(embedding, y) without return types