I have had this problem also since last year. Enough that I didn't even consider it was my new UPS causing problems. I paid to have my 27" 2019 retina 5K also.
So I had asked and someone said the iMac is a workhorse and the UPS likes to take breaks and it was causing my iMac to freeze and...