I’m not aware of a code issue with it (doesn’t mean there isn’t one though). But from a common sense standpoint, I wouldn’t do it. Someone spent the money for a UPS because it was critical enough of an operation that it warranted protection from unintended shutdowns. If one of the unintentional causes is a failed cable and that failed cable then damages the UPS circuit, you have wasted the money.
There was a high profile failure along those lines at the Bellagio Hotel Casino in Vegas a decade or so ago. The feed cables from the substation were in a trench, then the cables from the backup generator were laid in on top of them in the same trench. When the utility feeders caught fire, they burned up the backup cables at the same time. So the generators came on, but immediately tripped and everything in the hotel and casino went dark. Same basic principle ...