Solved by albanD in post #2 
              
              
                The autograd.grad function returns an object that match the inputs argument. 
When you do (foo,) you unpack a tuple of size 1 into the variable foo: (foo,) = (2,) will make foo == 2.