def METHOD_NAME(self):
    rpn_encoder = _RpnLabelEncoder(
        anchor_format="xyxy",
        ground_truth_box_format="xyxy",
        positive_threshold=0.7,
        negative_threshold=0.3,
        positive_fraction=0.5,
        samples_per_image=2,
    )
    rois = tf.constant(
        [
            [0, 0, 5, 5],
            [2.5, 2.5, 7.5, 7.5],
            [5, 5, 10, 10],
            [7.5, 7.5, 12.5, 12.5],
        ]
    )
    # the 3rd box will generate 0 IOUs and not sampled.
    gt_boxes = tf.constant([[10, 10, 15, 15], [2.5, 2.5, 7.5, 7.5]])
    gt_classes = tf.constant([2, 10, -1], dtype=tf.int32)
    gt_classes = gt_classes[..., tf.newaxis]
    box_targets, box_weights, cls_targets, cls_weights = rpn_encoder(
        rois, gt_boxes, gt_classes
    )
    # all rois will be matched to the 2nd gt boxes, and encoded
    expected_box_targets = (
        tf.constant(
            [
                [0.5, 0.5, 0.0, 0.0],
                [0.0, 0.0, 0.0, 0.0],
                [-0.5, -0.5, 0.0, 0.0],
                [0.5, 0.5, 0.0, 0.0],
            ]
        )
        / 0.1
    )
    self.assertAllClose(expected_box_targets, box_targets)
    # only foreground and background classes
    self.assertAllClose(tf.reduce_max(cls_targets), 1.0)
    self.assertAllClose(tf.reduce_min(cls_targets), 0.0)
    # all weights between 0 and 1
    self.assertAllClose(tf.reduce_max(cls_weights), 1.0)
    self.assertAllClose(tf.reduce_min(cls_weights), 0.0)
    self.assertAllClose(tf.reduce_max(box_weights), 1.0)
    self.assertAllClose(tf.reduce_min(box_weights), 0.0)