Hi,
The inplace operation happen when you do reset[layer] = XXX. This writes s subset of the Tensor inplace.
You can avoid doing this by just having reset being a list.
And if later you need to convert the content of that list into a single Tensor, you can do torch.stack(reset, dim=0).