You already found the corresponding code in Pytorch… But indeed it is less straight forward. Anyway if you re lazy you just copy-past the right stuff it will take you 10min maximum to recode the whole model.
Good luck