RuntimeError: Cannot insert a Tensor that requires grad as a constant

Hi, did you ever find out what caused this error?
Because I’m getting the same error with very similar code, and any hints would be greatly appreciated!