nshrimali:

I am trying to extract layers using model.children() and slice the list to separate the encoder and decoder part.


If you are planning to extract the encoder/decoder layers via model.children() and use them in e.g. separate nn.Sequential modules, note that you would have to make sure these submodules can be executed sequentially without any functional calls in the original forward.
I would generally recommend to look into the model definition and make sure the forward is still executed as expected.