LibTorch Tensor Masking

Hey,

I have a tensor with size (1, 500, 9) and I want to get rows which satisfies condition (first_row_elem >= 0.3) of this tensor, yielding a tensor shape (1, N, 9 | N < 500).

In python I would do;

mask = tensor[:,:,0] >= 0.3
filtered_tensor = tensor[mask]

But using LibTorch C++ i did;

at::Tensor mask = boxes3d.slice(2, 0, 1) >= 0.3;
at::Tensor filtered_boxes = boxes3d.index({mask.squeeze(2)});

I was wondering if there were any better ways to do this in C++ LibTorch?