Hi,
The error mentions that you modify inplace a Tensor whole value is needed in the backward pass.
In particular here, it seems that the content of context is needed. And so if you do context *= maybe_dropout (which modifies it inplace), then you can’t backward anymore.
You need to make sure not to modify the original context:
context = context.clone() # Get new memory
context *= maybe_dropout # Now we can safely write inplace into it

Or
context = context * maybe_dropout # Use the out of place version