Why don’t you return two values from the forward function, the penultimate layer predictions as well as the final logits?
something like
lw_model = torch.nn.Sequential(*list(class_model.children())[:-1])
final_layer = list(class_model.children()))[-1]

and chain these two models to make the final prediction.