Multi-statement Table Valued Function causing massive PAGELATCH_EX waits
Since you are on SQL Server 2017 CU2 - you might be hitting this bug - Heavy tempdb contention occurs in SQL Server 2016 or 2017  . 

Update to atleast CU5 since CU5 has fixed above bug.

I would recommend CU12 (latest).