I found a problem with my code. I added with torch.no_grad(): before for-loop in evaluate function and it works fine. And I also calculate my training accuracy in the evaluate function. So I didn’t find an accurate and better solution rather to not to use the evaluate function on train_loader after train function.
for epoch in range(1, N):
    train(epoch)
    evaluate(train_loader)
    evaluate(dev_loader)