I am not sure in your particular code.
Taking a step back. You should not rely on getting the exact same results as depending on the hardware and version you have, the results might change.
This is due to floating points being non-exact and the fact that gradient descent has the tendency to increase any small difference very quickly. Leading to completely different results.
For stable models, you will get similar final loss and accuracy. But you won’t get the exact same solution.