If the error is still about “grads not defined”, then it must mean that you still haven’t completely restored the code that Tom was pointing out that was just provided to you in the template. One way to pursue a solution here would be to get a fresh clean copy of the notebook and then carefully “copy/paste” over just your code from the “YOUR CODE HERE” sections. It’s not illegal to modify code outside those boundaries, but you need to be very careful that you know what you are doing when you “go there”. Just deleting a bunch of lines they gave you if you’re not sure what they are for is a warning sign. The better approach is to study the template more carefully to understand the purpose of the lines in question.
Here’s a thread about how to get a clean copy of any of the notebooks in DLS if you are using the Coursera platform to take the courses. That link is also available from the DLS FAQ Thread, which is worth a look just on general principles if you haven’t previously seen it.