Ok so here's my problem, I have a 02 grand Cherokee h.o.4.7 with about 138,000 miles on it. I had a rough idle issue so I gave it a tune up (changed plugs, fuel/air filter, both upstream o2 sensors, cleaned throttle body , changed IAC and TPS sensors, oil change, pvc valve , fixed vaccum leaks. Took it out for a spin about 35 miles round trip. Mpgs shot up from about 14 to 22 . Going great until I come to a stop , rpms shoot down to about 300 /400 , wants to shut off but corrects itself and fluctuates but stays on. Take it back home and run a diagnostic on it Po175 and po172 and G-switch malfunction. After a few days later jeep dies on me after driving fine . Start it back up and sputters hard and dies, won't start anymore. Anybody have any ideas? Please and thank you in advance

Do the key dance to see if any new codes show up on the odometer readout (on/off, on/off on > read odometer)
If you overlook those other codes as maybe an anomaly...it sounds like your CkPS is out. - p0320
On your 4.7 it's located right above your starter.

It's probably not the plugs, but I would definitely replace them with new Chamion Coppers. They're what the 4.7 V8 likes. Do some searching if you want to confirm. It will probably like the cheap Coppers more, but again, that's probably not the actual problem. I'd do some searching and checking on this forum when replacing any part or doing any repair, really, cause the V8 is so finicky and particular about things. It's good to find out what's really recommended.

I replaced the factory o2 sensor (both upstream) to denso sensors , I was that the engine has problems reading them , is that true?

You used something other than Bosch. I'd trust them for now and look at why its getting extra fuel.

Fuel pressure

Restricted exhaust

A sensor is going bad and causing the PCM to chose the wrong fuel map. Then the O2 sensor sees a rich condition and the PCM trims back the fuel and when the LTFTs get to -20% fuel trim it gives the running rich codes.