How to select values from tensor contained in np.array

I have this huge tensor from which I just want to keep selected tensors.

Background - first contains coordinates of quadrilaterals being predicted.


    np.shape(coords_detached) =  (15969, 8)
    coords.shape() =   torch.Size([15969, 8])

Second contains same coordinates but filtered after selection using NMS, for this discussion just say I select 9 rows from above tensor. 8 coordinates + 1 confidence score
But NMS is being done in numpy so I detach the tensors.

  coords_nms = torch.tensor(nms_coords_, dtype=torch.float32)
            
    coords_nms.shape() =  torch.Size([9, 9])

So now I want to select just these 9 rows from the original tensor, coz it had the gradient information that gets lost during detach() and numpy nms.

I tried this :

 s = torch.ones_like(nms_coords_)
    s *=-1

    nms_coords = torch.where(coords == coords_nms[:,:-1], coords, s)
    nms_coords = nms_coords[nms_coords>=0]
    nms_coords.reshape(-1, 8)

to iterate through coords and match value coords_nms and just store those. but it needds same dimension at axis=0

The iterative loop would be the following but how to do it using tensor notation :

poo = []
    for x in coords:
        for z in nms_coords_:
           if sum(x[:] == z[:-1]) == 8 :
                poo.append(z[:-1])