Adding code to test the gradients