code: def forward_gpu(self, inputs):
      utils.nondeterministic("atomicAdd")
      self.retain_inputs((0, 1, 2))
      x, W, gy = inputs
  
      if self.reduce == "no":
          gy = gy[:, None]
  
      samples = self.samples
      wx = self.wx.astype(x.dtype, copy=False)
      g = cuda.elementwise(
          "T wx, T gy, int32 m",
          "T g",
          """
              T y;
              if (i % m == 0) {
                y = 1;
              } else {
                y = -1;
              }
  
              g = -y * gy / (1.0f + __expf(wx * y));
              """,
          "negative_sampling_calculate_g",
      )(wx, gy, self.sample_size + 1)
  
      cupy = cuda.cupy
      gx = cupy.zeros_like(x)
      n_in = x.shape[1]
      cuda.elementwise(
          "raw T g, raw T W, bool mask, raw S k, int32 c, int32 m",
          "T gx",
          """
              int d = i / c;
              T w = 0;
              if (mask == 1){
                  for (int j = 0; j < m; ++j) {
                    w += g[d * m + j] * W[k[d * m + j] * c + i % c];
                  }
              }
              gx = w;
              """,
          "negative_sampling_calculate_gx",
      )(
          g,
          W,
          self.ignore_mask[:, None],
          samples,
          n_in,
          self.sample_size + 1,
          gx,
      )
  
      gW = cupy.zeros_like(W)
      cuda.elementwise(
          "T g, raw T x, S k, bool mask, int32 c, int32 m",
          "raw T gW",
          """
              T gi = g;
              if (mask == 1) {
                  for (int j = 0; j < c; ++j) {
                    atomicAdd(&gW[k * c + j], gi * x[(i / m) * c + j]);
                  }
              }
              """,
          "negative_sampling_calculate_gw",
      )(
          g,
          x,
          samples,
          self.ignore_mask[:, None],
          n_in,
          self.sample_size + 1,
          gW,
      )
      return gx, None, gW
  
imports: import numpy
  import six
  import chainer
  from chainer import backend
  from chainer.backends import cuda
  from chainer import function_node
  from chainer import utils
  from chainer.utils import argument
  from chainer.utils import precision
  from chainer.utils import type_check
label_desc: Use image node_id 3 for calling the NegativeSamplingFunctionGrad obj's underlying member method code with example usage: obj.forward_gpu(inputs) and returns: gx,  None,  gW