Solved by albanD in post #2 
              
              
                Hi, 
It is a context manager. So it will enable the no_grad mode when you enter it and disable it when you leave the indentation. 
So no need to do it again inside the function, it will still be activated.