code: def test_op_mrcnn_mask_target():
      if default_device().device_type != "gpu":
          return
  
      num_rois = 2
      num_classes = 4
      mask_size = (3, 3)
      ctx = mx.gpu(0)
      # (B, N, 4)
      rois = mx.nd.array(
          [[[2.3, 4.3, 2.2, 3.3], [3.5, 5.5, 0.9, 2.4]]], ctx=ctx
      )
      gt_masks = mx.nd.arange(0, 4 * 32 * 32, ctx=ctx).reshape(
          1, 4, 32, 32
      )
  
      # (B, N)
      matches = mx.nd.array([[2, 0]], ctx=ctx)
      # (B, N)
      cls_targets = mx.nd.array([[2, 1]], ctx=ctx)
  
      mask_targets, mask_cls = mx.nd.contrib.mrcnn_mask_target(
          rois,
          gt_masks,
          matches,
          cls_targets,
          num_rois=num_rois,
          num_classes=num_classes,
          mask_size=mask_size,
      )
  
      # Ground truth outputs were generated with GluonCV's target generator
      # gluoncv.model_zoo.mask_rcnn.MaskTargetGenerator(1, num_rois, num_classes, mask_size)
      gt_mask_targets = mx.nd.array(
          [
              [
                  [
                      [
                          [2193.4, 2193.7332, 2194.0667],
                          [2204.0667, 2204.4, 2204.7334],
                          [2214.7334, 2215.0667, 2215.4],
                      ],
                      [
                          [2193.4, 2193.7332, 2194.0667],
                          [2204.0667, 2204.4, 2204.7334],
                          [2214.7334, 2215.0667, 2215.4],
                      ],
                      [
                          [2193.4, 2193.7332, 2194.0667],
                          [2204.0667, 2204.4, 2204.7334],
                          [2214.7334, 2215.0667, 2215.4],
                      ],
                      [
                          [2193.4, 2193.7332, 2194.0667],
                          [2204.0667, 2204.4, 2204.7334],
                          [2214.7334, 2215.0667, 2215.4],
                      ],
                  ],
                  [
                      [
                          [185.0, 185.33334, 185.66667],
                          [195.66667, 196.00002, 196.33334],
                          [206.33333, 206.66666, 207.0],
                      ],
                      [
                          [185.0, 185.33334, 185.66667],
                          [195.66667, 196.00002, 196.33334],
                          [206.33333, 206.66666, 207.0],
                      ],
                      [
                          [185.0, 185.33334, 185.66667],
                          [195.66667, 196.00002, 196.33334],
                          [206.33333, 206.66666, 207.0],
                      ],
                      [
                          [185.0, 185.33334, 185.66667],
                          [195.66667, 196.00002, 196.33334],
                          [206.33333, 206.66666, 207.0],
                      ],
                  ],
              ]
          ]
      )
  
      gt_mask_cls = mx.nd.array([[0, 0, 1, 0], [0, 1, 0, 0]])
      gt_mask_cls = gt_mask_cls.reshape(1, 2, 4, 1, 1).broadcast_axes(
          axis=(3, 4), size=(3, 3)
      )
  
      assert_almost_equal(
          mask_targets.asnumpy(), gt_mask_targets.asnumpy()
      )
      assert_almost_equal(mask_cls.asnumpy(), gt_mask_cls.asnumpy())
  
file_path: mxnet/tests/python/unittest/test_contrib_operator.py
imports: from __future__ import print_function
  import numpy
  import mxnet
  import random
  import itertools
  from numpy.testing import assert_allclose, assert_array_equal
  from mxnet.test_utils import *
  from common import assert_raises_cudnn_not_satisfied, xfail_when_nonstandard_decimal_separator
  import unittest
label_desc: Use image node_id 9 for calling a global function with example usage: test_op_mrcnn_mask_target() without return types