I agree with Tom that you cannot just think your code look that same and the results have to be the same.
If you want to make sure everything is the same, layer by layer, you need to have testing for that, from layer to sequential of layers between TensorFlow and Pytorch.
Just for reference: GitHub - jalola/compare-tensorflow-pytorch: Compare outputs between layers written in Tensorflow and layers written in Pytorch 4