Based on the discussions here 11 I found out that I should be using None for any inputs that I dont want the gradients for. so this is done.
I however would appreciate if anyone could tell me what that last snippet do though.
its greatly appreciated.