thanks for your help. So you suggest to do only this calculation:
losses_tr.append(loss.item())
print(
                    "Train_loss:{:.4f} Test_loss {:.4f}".format(
                        train_loss_t, last_loss_test
                    )
                )