Solved by ptrblck in post #4 
              
              
                You don’t need to set this attribute if you are using the posted code snippet and l1 won’t be updated. 
However, I would recommend to explicitly set it in case your code tries to use the gradients of the models in any way, which might be hard to debug later on.