Thank you for your answer.
I think, the above code is different
batch_idx is Image count,
ex)
boxes =  Image * index * 4  
score =  Image * index

I think, something like the code below
Is this right?@albanD @yf225
int64_t num_images = proposals.size(0);
torch::Device device = proposals.device();

objectness = objectness.detach();
objectness = objectness.reshape({ num_images, -1 });

std::vector<torch::Tensor> levels;
for (int64_t index = 0; index < num_anchors_per_level.size(); index++)
{
	levels.push_back(torch::full(num_anchors_per_level[index], index, torch::TensorOptions().device(device).dtype(at::kFloat)));
}

auto tensorlevels = torch::cat(levels, 0);

tensorlevels = tensorlevels.reshape({ 1,-1 }).expand_as(objectness);

auto top_n_idx = get_top_n_idx(objectness, num_anchors_per_level);
auto batch_idx = torch::arange(num_images, torch::TensorOptions().device(device));

std::vector<torch::Tensor> final_boxes, final_scores;

for (int64_t index = 0; index < num_images; index++)
{
	auto proposal = proposals[index].index_select(0, top_n_idx[index]);
	auto obj	= objectness[index].index_select(0, top_n_idx[index]);
	auto lvl	= tensorlevels[index].index_select(0, top_n_idx[index]);

	auto boxes = clip_boxes_to_image(proposal, image_shapes[index]);
	auto keep = remove_small_boxes(boxes, min_size_);
}