Measurement of longitudinal flow decorrelations in Pb+Pb collisions at \(\sqrt{s_{\text {NN}}}=2.76\) and 5.02 TeV with the ATLAS detector