RuntimeError                              Traceback (most recent call last)
<ipython-input-244-b5623f61a7a3> in <module>
----> 1 losses, model = train(model, dataloader, 5)

<ipython-input-242-54990647c901> in train(model, dataloader, num_epochs)
     13                 out = model(seq)
     14                 loss = criterion(out, label)
---> 15                 loss.backward(retain_graph=True)
     16                 optimizer.step()
     17 

~\anaconda3\envs\MarketingAnalytics\lib\site-packages\torch\tensor.py in backward(self, gradient, retain_graph, create_graph)
    183                 products. Defaults to ``False``.
    184         """
--> 185         torch.autograd.backward(self, gradient, retain_graph, create_graph)
    186 
    187     def register_hook(self, hook):

~\anaconda3\envs\MarketingAnalytics\lib\site-packages\torch\autograd\__init__.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables)
    123         retain_graph = create_graph
    124 
--> 125     Variable._execution_engine.run_backward(
    126         tensors, grad_tensors, retain_graph, create_graph,
    127         allow_unreachable=True)  # allow_unreachable flag

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [128, 512]], which is output 0 of TBackward, is at version 2; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

@albanD This is the full traceback
​