In the M54, the thermostat wires are to send current through a heating element that will cause the thermostat to open earlier or more than it normally would. The ECU controls that current as needed based on speed and power demand. If no control current is sent, it works just like a regular fully mechanical wax thermostat.
https://us.autologic.com/news/electr...t-how-it-works
The cylinder head temp sensor, on the left side of the head, towards the rear (around cylinder 5) is what the ECU uses, and is also used for the temp gauge on the instrument panel (although by default the mapping from temp to needle angle is not linear).
The temp sensor in the lower radiator hose is used to control the speed of the auxiliary fan.