Found how to do it:
void Training::swapTensorRow(torch::Tensor tensorA, int indexA, torch::Tensor tensorB, int indexB)
{
    torch::Tensor cache=tensorA.index({indexA}).clone();
    tensorA.index_put_({indexA},tensorB.index({indexB}));
    tensorB.index_put_({indexB},cache);
}

More detail about indexing PyTorch vs LibTorch: https://pytorch.org/cppdocs/notes/tensor_indexing.html 5