Just realized that the flow of the code is not sequential as I thought. My actual code structure looks like:
class net1()
…
…
…
def forward(self, x):
print(‘2’)
out = self.layerA(x)
print(‘3’)
out = self.layerB(out)
pLoss = calcPLoss(out)
out = self.layerC(out)
return out, pLoss
class net2()
…
layerBB = make_layer_from_net1
…
def forward(self, x):
out = self.layerAA(x)
print(‘1’)
out, pLoss = self.layerBB(out)
print(‘4’)
out = self.layerCC(out)
return out, pLoss
train()
…
out, pLoss = net(input)
loss = criterion(out, input)
loss = loss + pLoss
loss.backward()
When I execute this:
I get
1
2
3
2
I am surprised to see this. And I am getting error at the statement between print(“2”) and print(“3”).  Tuple object has no ‘dim’!
I am not sure if all these make sense to you. Regardless, thank you so much for trying to help.