code: def test_backward_compare_with_numpy(self, backend_config):
      # This test compares gradients with that of NumPy mode.
  
      rng = numpy.random.RandomState()
      rng_state = rng.get_state()
  
      # Call NumPy mode link and save samples
      x = chainer.Variable(self.x)
      t = chainer.Variable(self.t, requires_grad=False)
      link = self.create_link(rng)
  
      y, samples = link(x, t, return_samples=True)
  
      y.backward()
      assert t.grad is None
      gw_cpu = link.W.grad
      gx_cpu = x.grad
  
      # Call GPU mode link
      rng.set_state(rng_state)
      link = self.create_link(rng)
      link.to_device(backend_config.device)
      x = chainer.Variable(backend_config.get_array(self.x))
      t = chainer.Variable(
          backend_config.get_array(self.t), requires_grad=False
      )
      samples = backend_config.get_array(samples)
      y = self.call_link_with_samples(samples, lambda: link(x, t))
  
      y.backward()
      assert t.grad is None
      gw_gpu = link.W.grad
      gx_gpu = x.grad
  
      # Compare gradients from CPU and GPU modes
      testing.assert_allclose(
          gx_cpu, gx_gpu, **self.test_backward_options
      )
      testing.assert_allclose(
          gw_cpu, gw_gpu, **self.test_backward_options
      )
  
file_path: chainer/tests/chainer_tests/links_tests/loss_tests/test_negative_sampling.py
imports: import unittest
  import numpy
  import chainer
  from chainer import backend
  from chainer.backend import CpuDevice
  from chainer import links
  from chainer import testing
label_desc: Use image node_id 8 for calling the TestNegativeSampling obj's underlying member method code with example usage: obj.test_backward_compare_with_numpy(backend_config) without return types