Select a detection tensor output where its confidence above threshold

I try to achieve this code

pred = pred[pred[:, 4] > opt.conf_thres]

Pred has [Nx518] where n is the number of detection

auto pred = detection_model.forward_model(im_blob).at(0).squeeze();
//pred has shape [Nx518]
auto conf_mask = (, 4) > opt.conf_thres);
auto filtered_index = conf_mask.nonzero().squeeze();
pred = torch::index_select(pred, 0, filtered_index);

Is my C++ solution considered bad practice ? is there any other solution?

I have the same question with you too, do you get the answer?