SGD intro not working after first frame

I have the following code. When I run it it just draws one frame and then does not update. I added a print statement to add the calls to animate and saw that animate is only being called once. Any idea why?

a_guess = 1
b_guess = 2
lr = 0.01

from matplotlib import pyplot as plt, rcParams, animation, rc

def upd():
    global a_guess, b_guess
    print("upd {}, {}".format(a_guess, b_guess))
    y_pred = linear(a_guess, x, b_guess)
    dxdb = 2 *(y_pred - y)
    dxda = x * dxdb
    a_guess -= lr * dxda.mean()
    b_guess -= lr * dxdb.mean()
def animate(i):
    print("animate {}".format(i))
    global a_guess, b_guess
    line.set_ydata(linear(a_guess, x, b_guess))
    return line

fig = plt.figure(dpi=100, figsize=(5, 4))
plt.scatter(x, y)
line, = plt.plot(x, linear(a_guess, x, b_guess))

ani = animation.FuncAnimation(fig, animate, frames = np.arange(0, 1000), interval=1000)