def METHOD_NAME(self,
                       conf_loss,
                       targets_label,
                       bg_index,
                       mine_neg_ratio=0.01):
    pos = (targets_label != bg_index).astype(conf_loss.dtype)
    num_pos = pos.sum(axis=1, keepdim=True)
    neg = (targets_label == bg_index).astype(conf_loss.dtype)
    conf_loss = conf_loss.detach() * neg
    loss_idx = conf_loss.argsort(axis=1, descending=True)
    idx_rank = loss_idx.argsort(axis=1)
    num_negs = []
    for i in range(conf_loss.shape[0]):
        cur_num_pos = num_pos[i]
        num_neg = paddle.clip(
            cur_num_pos * self.neg_pos_ratio, max=pos.shape[1])
        num_neg = num_neg if num_neg > 0 else paddle.to_tensor(
            [pos.shape[1] * mine_neg_ratio])
        num_negs.append(num_neg)
    num_negs = paddle.stack(num_negs).expand_as(idx_rank)
    neg_mask = (idx_rank < num_negs).astype(conf_loss.dtype)
    return (neg_mask + pos).astype('bool')