Without seeing the code I would recommend to remove obvious inplace operations (e.g. via += etc. or via the inplace version of some operations such as tensor.add_()).
If that’ doesn’t help, you could add .clone() statements to return tensors to further isolate which operation is causing the inplace manipulation and thus the error.