code: def _check_mask_head_loss_pre(self, xp):
      n_inst = 12
      segm_size = 28
      rois = [
          xp.array(((4, 1, 6, 3),), dtype=np.float32),
          xp.array(((0, 1, 2, 3), (5, 4, 10, 6)), dtype=np.float32),
          xp.array(((10, 4, 12, 10),), dtype=np.float32),
      ]
      roi_indices = [
          xp.array((0,), dtype=np.int32),
          xp.array((1, 0), dtype=np.int32),
          xp.array((1,), dtype=np.int32),
      ]
      masks = [
          _random_array(xp, (n_inst, 60, 70)),
          _random_array(xp, (n_inst, 60, 70)),
      ]
      bboxes = [mask_to_bbox(mask) for mask in masks]
      labels = [
          xp.array((1,), dtype=np.int32),
          xp.array((10, 4), dtype=np.int32),
          xp.array((3,), dtype=np.int32),
      ]
      rois, roi_indices, gt_segms, gt_mask_labels = mask_head_loss_pre(
          rois, roi_indices, masks, bboxes, labels, segm_size
      )
  
      self.assertEqual(len(rois), 3)
      self.assertEqual(len(roi_indices), 3)
      self.assertEqual(len(gt_segms), 3)
      self.assertEqual(len(gt_mask_labels), 3)
      for l in range(3):
          self.assertIsInstance(rois[l], xp.ndarray)
          self.assertIsInstance(roi_indices[l], xp.ndarray)
          self.assertIsInstance(gt_segms[l], xp.ndarray)
          self.assertIsInstance(gt_mask_labels[l], xp.ndarray)
  
          self.assertEqual(rois[l].shape[0], roi_indices[l].shape[0])
          self.assertEqual(rois[l].shape[0], gt_segms[l].shape[0])
          self.assertEqual(rois[l].shape[0], gt_mask_labels[l].shape[0])
          self.assertEqual(rois[l].shape[1:], (4,))
          self.assertEqual(roi_indices[l].shape[1:], ())
          self.assertEqual(
              gt_segms[l].shape[1:], (segm_size, segm_size)
          )
          self.assertEqual(gt_mask_labels[l].shape[1:], ())
          self.assertEqual(gt_segms[l].dtype, np.float32)
          self.assertEqual(gt_mask_labels[l].dtype, np.int32)
  
imports: from __future__ import division
  import numpy
  import unittest
  import chainer
  from chainer import testing
  from chainer.testing import attr
  from chainercv.links.model.fpn import mask_head_loss_post
  from chainercv.links.model.fpn import mask_head_loss_pre
  from chainercv.links.model.fpn import MaskHead
  from chainercv.utils import mask_to_bbox
label_desc: Use image node_id 1 for calling the TestMaskHeadLoss obj's underlying member method code with example usage: obj._check_mask_head_loss_pre(xp) without return types