code: def check_anchor_target_creator(
      self, anchor_target_layer, bbox, anchor, img_size
  ):
      xp = cuda.get_array_module(bbox)
  
      loc, label = self.anchor_target_layer(bbox, anchor, img_size)
  
      # Test types
      self.assertIsInstance(loc, xp.ndarray)
      self.assertIsInstance(label, xp.ndarray)
  
      # Test shapes
      self.assertEqual(loc.shape, (self.n_anchor, 4))
      self.assertEqual(label.shape, (self.n_anchor,))
  
      # Test dtype
      self.assertEqual(loc.dtype, np.float32)
      self.assertEqual(label.dtype, np.int32)
  
      # Test ratio of foreground and background labels
      np.testing.assert_equal(
          cuda.to_cpu(utils.force_array(xp.sum(label >= 0))),
          self.n_sample,
      )
      n_pos = cuda.to_cpu(utils.force_array(xp.sum(label == 1)))
      n_neg = cuda.to_cpu(utils.force_array(xp.sum(label == 0)))
      self.assertLessEqual(n_pos, self.n_sample * self.pos_ratio)
      self.assertLessEqual(n_neg, self.n_sample - n_pos)
  
file_path: chainercv/tests/links_tests/model_tests/faster_rcnn_tests/utils_tests/test_anchor_target_creator.py
imports: import unittest
  import numpy
  from chainer.backends import cuda
  from chainer import testing
  from chainer.testing import attr
  from chainer import utils
  from chainercv.links.model.faster_rcnn import AnchorTargetCreator
  from chainercv.utils import generate_random_bbox
label_desc: Use image node_id 2 for calling the TestAnchorTargetCreator obj's underlying member method code with example usage: obj.check_anchor_target_creator(anchor_target_layer, bbox, anchor, img_size) without return types