Your code is quite unreadable at the moment, which makes debugging hard.
You can post code snippets by wrapping them into three backticks ```.
Based on the error message, the model output or more likely the target tensor passed to nn.CrossEntropyLoss or nn.NLLLoss is on the CPU while it should be on the GPU.