class_docstr: Negative sampling based skip-gram
class_docstr_tok: ["Negative","sampling","based","skip-gram"]
docstr: get grad for negative samples
docstr_tok: ["get","grad","for","negative","samples"]
code: def fast_neg_bp(self, emb_neg_u, emb_neg_v, first_flag):
      """get grad for negative samples"""
      neg_score = torch.sum(torch.mul(emb_neg_u, emb_neg_v), dim=1)
      neg_score = torch.clamp(neg_score, max=6, min=-6)
      # [batch_size * negative, 1]
      score = -self.fast_sigmoid(neg_score).unsqueeze(1)
      if self.record_loss:
          if first_flag:
              self.loss_fst.append(
                  self.negative
                  * self.neg_weight
                  * torch.mean(self.fast_logsigmoid(-neg_score)).item()
              )
          else:
              self.loss_snd.append(
                  self.negative
                  * self.neg_weight
                  * torch.mean(self.fast_logsigmoid(-neg_score)).item()
              )
  
      grad_u_neg = self.neg_weight * score * emb_neg_v
      grad_v_neg = self.neg_weight * score * emb_neg_u
  
      return grad_u_neg, grad_v_neg
  
imports: import random
  import numpy
  import torch
  import torch.multiprocessing
  import torch.nn
  import torch.nn.functional
  from torch.multiprocessing import Queue
  from torch.nn import init
label_desc: Use image node_id 10 for calling the SkipGramModel obj's underlying member method code with example usage: obj.fast_neg_bp(emb_neg_u, emb_neg_v, first_flag) and returns: grad_u_neg,  grad_v_neg