State Transition of Dendritic Spines Improves Learning of Sparse Spiking Neural Networks