code: def _check_forward(
      self, mb_locs, mb_confs, gt_mb_locs, gt_mb_labels, k
  ):
      if self.variable:
          mb_locs = chainer.Variable(mb_locs)
          mb_confs = chainer.Variable(mb_confs)
          gt_mb_locs = chainer.Variable(gt_mb_locs)
          gt_mb_labels = chainer.Variable(gt_mb_labels)
  
      loc_loss, conf_loss = multibox_loss(
          mb_locs, mb_confs, gt_mb_locs, gt_mb_labels, k
      )
  
      self.assertIsInstance(loc_loss, chainer.Variable)
      self.assertEqual(loc_loss.shape, ())
      self.assertEqual(loc_loss.dtype, mb_locs.dtype)
  
      self.assertIsInstance(conf_loss, chainer.Variable)
      self.assertEqual(conf_loss.shape, ())
      self.assertEqual(conf_loss.dtype, mb_confs.dtype)
  
      if self.variable:
          mb_locs = mb_locs.array
          mb_confs = mb_confs.array
          gt_mb_locs = gt_mb_locs.array
          gt_mb_labels = gt_mb_labels.array
  
      mb_locs = cuda.to_cpu(mb_locs)
      mb_confs = cuda.to_cpu(mb_confs)
      gt_mb_locs = cuda.to_cpu(gt_mb_locs)
      gt_mb_labels = cuda.to_cpu(gt_mb_labels)
      loc_loss = cuda.to_cpu(loc_loss.array)
      conf_loss = cuda.to_cpu(conf_loss.array)
  
      n_positive_total = 0
      expect_loc_loss = 0
      expect_conf_loss = 0
      for i in six.moves.xrange(gt_mb_labels.shape[0]):
          n_positive = 0
          negatives = []
          for j in six.moves.xrange(gt_mb_labels.shape[1]):
              loc = F.huber_loss(
                  mb_locs[np.newaxis, i, j],
                  gt_mb_locs[np.newaxis, i, j],
                  1,
              ).array
              conf = F.softmax_cross_entropy(
                  mb_confs[np.newaxis, i, j],
                  gt_mb_labels[np.newaxis, i, j],
              ).array
  
              if gt_mb_labels[i, j] > 0:
                  n_positive += 1
                  expect_loc_loss += loc
                  expect_conf_loss += conf
              else:
                  negatives.append(conf)
  
          n_positive_total += n_positive
          if n_positive > 0:
              expect_conf_loss += sum(
                  sorted(negatives)[-n_positive * k :]
              )
  
      if n_positive_total == 0:
          expect_loc_loss = 0
          expect_conf_loss = 0
      else:
          expect_loc_loss /= n_positive_total
          expect_conf_loss /= n_positive_total
  
      np.testing.assert_almost_equal(
          loc_loss, expect_loc_loss, decimal=2
      )
      np.testing.assert_almost_equal(
          conf_loss, expect_conf_loss, decimal=2
      )
  
imports: from __future__ import division
  import numpy
  import six
  import unittest
  import chainer
  from chainer.backends import cuda
  import chainer.functions
  from chainer import testing
  from chainermn import create_communicator
  from chainercv.links.model.ssd import multibox_loss
  from chainercv.utils.testing import attr
label_desc: Use image node_id 2 for calling the TestMultiboxLoss obj's underlying member method code with example usage: obj._check_forward(mb_locs, mb_confs, gt_mb_locs, gt_mb_labels, k) without return types