Hard to say which code was responsible for the error but assigning values to a tensor is in place and can produce these errors.
tensor_name[0:2, 3] = 1 is forbidden to do on any tensor that is used in the model before the backpropagation has happened. Hard to debug though, maybe someone knows of a tool?