It's a head temperature sensor, and it is under the intake manifold.
If you think that you have a bad sensor because of the weird things that the gauge is doing and what seems like false overheat warnings, you are almost certainly wrong. It's much more likely that you really are overheating due to tiny cracks in the plastic parts of the cooling system and or problems with the hydraulic fan. The gauge is scaled, so it is possible for it to go all the way to the "H", and then all the way back to the center point after only having the key off for a minute.