Yes, your modification does fix the error. Thanks a lot!
However, the error message is a bit cryptic since it arises from pytorch back-propagation internals. If back-propagation requires contiguous tensors, it may be useful to have an assertion like error check somewhere to prevent coders from using discontiguous trainable tensors.