Grokking and Generalization Collapse: Insights from \texttt{HTSR} theory