def METHOD_NAME(self, overlaps, gt_labels=None):
    """Assign w.r.t. the overlaps of bboxes with gts.  """
    num_gts, num_bboxes = overlaps.shape[0], overlaps.shape[1]
    # 1. assign -1
    assigned_gt_inds = paddle.full((num_bboxes, ), -1, dtype='int32')
    # for each anchor, which gt best overlaps with it
    # for each anchor, the max iou of all gts
    max_overlaps, argmax_overlaps = paddle.topk(overlaps, k=1, axis=0)
    # for each gt, which anchor best overlaps with it
    # for each gt, the max iou of all proposals
    gt_max_overlaps, gt_argmax_overlaps = paddle.topk(overlaps, k=1, axis=1) 
    # 2. assign negative: below the negative inds are set to be 0
    match_labels = paddle.full(argmax_overlaps.shape, -1, dtype='int32')
    match_labels = paddle.where(max_overlaps < self.neg_iou_thr,
                        paddle.zeros_like(match_labels), match_labels)
    # 3. assign positive: above positive IoU threshold
    argmax_overlaps_int32 = paddle.cast(argmax_overlaps, 'int32')
    match_labels = paddle.where(max_overlaps >= self.pos_iou_thr,
                            argmax_overlaps_int32 + 1, match_labels)
    assigned_gt_inds = match_labels
    if self.match_low_quality:
        # Low-quality matching will overwirte the assigned_gt_inds
        # assigned in Step 3. Thus, the assigned gt might not be the
        # best one for prediction.
        # For example, if bbox A has 0.9 and 0.8 iou with GT bbox
        # 1 & 2, bbox 1 will be assigned as the best target for bbox A
        # in step 3. However, if GT bbox 2's gt_argmax_overlaps = A,
        # bbox A's assigned_gt_inds will be overwritten to be bbox B.
        # This might be the reason that it is not used in ROI Heads.
        for i in range(num_gts):
            if gt_max_overlaps.numpy()[i] >= self.min_pos_iou:
                if self.gt_max_assign_all:
                    equal_x_np = overlaps[i, :].numpy()
                    equal_y_np = gt_max_overlaps[i].numpy()
                    max_iou_inds = np.equal(equal_x_np, equal_y_np)
                    max_iou_inds = paddle.to_tensor(max_iou_inds)
                    max_iou_inds = paddle.reshape( max_iou_inds, [1,max_iou_inds.shape[0]] )
                    match_labels_gts = paddle.full(max_iou_inds.shape, i+1, dtype='int32')
                    match_labels = paddle.where(max_iou_inds, match_labels_gts, match_labels)
                    assigned_gt_inds = match_labels
                else:
                    assigned_gt_inds[gt_argmax_overlaps[i]] = i + 1
    if gt_labels is not None:
        # consider multi-class case (AVA)
        assert len(gt_labels[0]) > 1
        assigned_labels = paddle.full([num_bboxes, len(gt_labels[0])], 0, dtype='float32')
        assigned_gt_inds_reshape = assigned_gt_inds.reshape([assigned_gt_inds.shape[1]])
        pos_inds = paddle.nonzero( assigned_gt_inds_reshape , as_tuple=False)
        pos_inds_num = float(paddle.numel(pos_inds))
        if pos_inds_num > 0:
            pos_inds = paddle.squeeze(pos_inds, axis = 1 )
            assigned_gt_inds_squeeze = paddle.squeeze(assigned_gt_inds, axis=0)
            assigned_gt_inds_select = paddle.index_select(assigned_gt_inds_squeeze, pos_inds) - 1
            gt_labels_select = paddle.index_select(gt_labels, assigned_gt_inds_select)
            A = assigned_gt_inds_squeeze
            X = assigned_gt_inds_squeeze - 1
            Y = paddle.zeros_like(X)
            if A.shape[0]==1:
                if float(A) > 0:
                    T=X
                else:
                    T=Y
            else:
                T = paddle.where(A>0, X, Y)
            S = paddle.index_select(gt_labels, T)
            AE = paddle.expand(A, [S.shape[1], A.shape[0]]) 
            AET = paddle.transpose(AE, perm=[1, 0])
            R = paddle.where(AET>0, S, assigned_labels) 
            assigned_labels = R
    else:
        assigned_labels = None
    ret = AssignResult(
        num_gts,
        assigned_gt_inds,
        max_overlaps,
        labels=assigned_labels)
    return ret