Not getting the right output for compute_gradient function

This is my compute_gradient function. I am not able to understand what I did wrong here because I am not getting the right output. I even tried with the hints but it’s still not giving me the right answer.

Moderator edit, code removed.

This is the output I am getting, it’s wrong. If anybody has done this already, please help me out !!

Please do not post your code on the forum. That is not allowed by the Code of Conduct.

I am sorry, I was not aware of that. Won’t happen again.