code: def check_proposal_target_creator(
      self, roi, mask, label, proposal_target_creator
  ):
      xp = cuda.get_array_module(roi)
      bbox = mask_to_bbox(mask)
      (
          sample_roi,
          gt_roi_mask,
          gt_roi_label,
          gt_roi_loc,
      ) = proposal_target_creator(
          roi, mask, label, bbox, mask_size=self.mask_size
      )
  
      # Test types
      self.assertIsInstance(sample_roi, xp.ndarray)
      self.assertIsInstance(gt_roi_loc, xp.ndarray)
      self.assertIsInstance(gt_roi_mask, xp.ndarray)
      self.assertIsInstance(gt_roi_label, xp.ndarray)
  
      sample_roi = cuda.to_cpu(sample_roi)
      gt_roi_loc = cuda.to_cpu(gt_roi_loc)
      gt_roi_mask = cuda.to_cpu(gt_roi_mask)
      gt_roi_label = cuda.to_cpu(gt_roi_label)
  
      # Test shapes
      self.assertEqual(sample_roi.shape, (self.n_sample, 4))
      self.assertEqual(gt_roi_loc.shape, (self.n_sample, 4))
      self.assertEqual(
          gt_roi_mask.shape,
          (self.n_sample, self.mask_size, self.mask_size),
      )
      self.assertEqual(gt_roi_label.shape, (self.n_sample,))
  
      # Test foreground and background labels
      np.testing.assert_equal(np.sum(gt_roi_label >= 0), self.n_sample)
      n_pos = np.sum(gt_roi_label >= 1)
      n_neg = np.sum(gt_roi_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/experimental_tests/links_tests/model_tests/fcis_tests/utils_tests/test_proposal_target_creator.py
imports: import unittest
  import numpy
  from chainer.backends import cuda
  from chainer import testing
  from chainer.testing import attr
  from chainercv.experimental.links.model.fcis import ProposalTargetCreator
  from chainercv.utils import generate_random_bbox
  from chainercv.utils import mask_to_bbox
label_desc: Use image node_id 2 for calling the TestProposalTargetCreator obj's underlying member method code with example usage: obj.check_proposal_target_creator(roi, mask, label, proposal_target_creator) without return types