Thanks for the explanation. Although I tried to declare the patch_embed_2 at last in init(), the training process is still being altered. This I guess is because after model declaration there might be some other part of code that uses pseudorandom number and declaring patch_embed_2 is changing the assigned random numbers for that part of the code.