Finding the nearest matching descriptor

I’m using the following code to retrieve the nearest matching descriptors index and value.

def approx(self, db_desc, query_desc, n_neighbors):

    db_features = __to_unit_torch__(db_desc, cuda="cuda")
    query__desc = __to_unit_torch__(query_desc, cuda="cuda")
    with torch.no_grad():
        d = 1. - torch.matmul(db_features, query__desc.transpose(0,1))
        values, indices = torch.topk(d, n_neighbors, dim=1, largest=False, sorted=True)
        return indices.cpu().numpy()

why is that it always returns 0?