Also, from one of your past answer, I found that I didn’t remove the hooks, which essencially caused the problems.
total_feat_out = []

def hook_fn_forward(module, input, output):
    total_feat_out.append(output) 
    print(output.shape)

modules = model_ft.named_children()
handles = {}
for name, module in modules:
    handles[name] = module.register_forward_hook(hook_fn_forward)

model_ft.eval() 
with torch.no_grad():
    pred = model_ft(dat)
    for k, v in handles.items():
        handles[k].remove()
``