def METHOD_NAME(self, feats, roi, rois_num):
    roi = paddle.concat(roi) if len(roi) > 1 else roi[0]
    if len(feats) == 1:
        rois_feat = paddle.vision.ops.roi_align(
            x=feats[self.start_level],
            boxes=roi,
            boxes_num=rois_num,
            output_size=self.resolution,
            spatial_scale=self.spatial_scale[0],
            aligned=self.aligned)
    else:
        offset = 2
        k_min = self.start_level + offset
        k_max = self.end_level + offset
        if hasattr(paddle.vision.ops, "distribute_fpn_proposals"):
            distribute_fpn_proposals = getattr(paddle.vision.ops,
                                               "distribute_fpn_proposals")
        else:
            distribute_fpn_proposals = ops.distribute_fpn_proposals
        rois_dist, restore_index, rois_num_dist = distribute_fpn_proposals(
            roi,
            k_min,
            k_max,
            self.canconical_level,
            self.canonical_size,
            rois_num=rois_num)
        rois_feat_list = []
        for lvl in range(self.start_level, self.end_level + 1):
            roi_feat = paddle.vision.ops.roi_align(
                x=feats[lvl],
                boxes=rois_dist[lvl],
                boxes_num=rois_num_dist[lvl],
                output_size=self.resolution,
                spatial_scale=self.spatial_scale[lvl],
                sampling_ratio=self.sampling_ratio,
                aligned=self.aligned)
            rois_feat_list.append(roi_feat)
        rois_feat_shuffle = paddle.concat(rois_feat_list)
        rois_feat = paddle.gather(rois_feat_shuffle, restore_index)
    return rois_feat