Thanks for immediate response.
I have changed
loss_tr = torch.nn.CrossEntropyLoss()#MyCrossEntropyLoss().to(device)
loss_fn = torch.nn.CrossEntropyLoss()

to
loss = torch.nn.CrossEntropyLoss()

But it still shows this error