Thank you albanD
definitely it helps!
so if i understand properly this part



 albanD:

The difference is that one refers to only a given variable on which it’s called. The other affects all operations taking place within the with statement.


(please anyone correct me if i’m wrong) we can use both method exchangeably and it should have same result
so
        with torch.no_grad():
            return policy_net(state).max(1)[1].view(1, 1)

should have similar effect as
       return policy_net(state).detach().max(1)[1].view(1, 1)

thanx again for your help!