Solved by ptrblck in post #2 
              
              
                The print statement might be buggy, if you are directly printing c in the lambda expression as explained here, so you might need to assign the value of c as a new argument to the lambda function via: 
lambda grad, c=c: print(c, grad)