DLS Course 5, Week 1, Assignment 3, djmodel

I think this thread covers your point.
What you needed is;

LSTM_cell = LSTM(n_a, return_state = True)

to reset incorrect state caused by debugging, error or any others.