I am currently reading David Tong's notes on statistical physics (Page 33) where, just before finishing the derivation of the classical partition function, he obtains the following equation $$ Z=\int{dqdpdp' e^{-\beta V(q)} \langle{p|q}\rangle \langle{p|e^{-\beta\hat{p}^2/2m}|p'}\rangle \langle{p'|q}\rangle }. $$ I am stuck at this point, mainly because I am not that used to work with quantum physics, so I don't know how to compute $\langle{p|e^{-\beta\hat{p}^2/2m}|p'}\rangle$
Just by looking at the solution and trying to guess, the only thing I can come up with is that$$ \langle{p|e^{-\beta\hat{p}^2/2m}|p'}\rangle = e^{-\beta p^2/2m} \langle{p|p'}\rangle = e^{-\beta p^2/2m} \delta (p'-p) $$ But even if that was correct and not a stupid guess, I still wouldn't know why it holds.