It seems you are trying to load the model directly via:
model = torch.load(f"{model_name}.pth", map_location=torch.device('cpu'))

instead of creating the model and loading its state_dict later.
The former approach might yield side effects, which apparently might be this device mismatch.
I would recommend to use the state_dict approach and try to fix the shape mismatches in the cell before the mentioned one.
PS: please post code snippets by wrapping them into three backticks, since the images are too small to recognize the error properly and they cannot be indexed by the search engine.