code: def forward(self, x, targets):
      batchSize = x.size(0)
      K = x.size(1) - 1
      Pnt = 1 / float(self.nLem)
      Pns = 1 / float(self.nLem)
  
      # eq 5.1 : P(origin=model) = Pmt / (Pmt + k*Pnt)
      Pmt = x.select(1, 0)
      Pmt_div = Pmt.add(K * Pnt + self.eps)
      lnPmt = torch.div(Pmt, Pmt_div)
  
      # eq 5.2 : P(origin=noise) = k*Pns / (Pms + k*Pns)
      Pon_div = x.narrow(1, 1, K).add(K * Pns + self.eps)
      Pon = Pon_div.clone().fill_(K * Pns)
      lnPon = torch.div(Pon, Pon_div)
  
      # equation 6 in ref. A
      lnPmt.log_()
      lnPon.log_()
  
      lnPmtsum = lnPmt.sum(0)
      lnPonsum = lnPon.view(-1, 1).sum(0)
  
      loss = -(lnPmtsum + lnPonsum) / batchSize
  
      return loss
  
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 2 for calling the NCECriterion obj's underlying member method code with example usage: obj.forward(x, targets) and returns: loss