Porting the code of the book "Mastering pytorch" to pytorch V2
I share here the porting of the code to pytorch V2. The original code is proposed in the book "Mastering Pytorch", by Ashish Ranjan Jha, first published in Feb. 2021 by Packt Publishing. My intention is to ease people who would like to use a more recent version of Pytorch.