Compute_gradient not getting expected output

Reposted Comupute_gradient