Subaru loss of power

Help, my Legacy sedan is not behaving well. On more than one occasion, when pressing on the accelerator, the rpms do not rise. I put it in park and try to press gas pedal, nothing. Turn the car off and let rest for a few minutes, then start it up again, and it’s fine…

Is the check engine light on? Even if it isn’t, if you go to an auto parts store, they may read your codes for free, but you need to do this within three drive cycles of the occurrence. Once you do that, post the code number here. It will be in a format starting with P followed by 4 numbers, like P0303.

Also what year Legacy. Need to know if it has a drive by wire throttle.

Yup.
We need to know the model year, the odometer mileage, and the maintenance history of this mystery Legacy over the past 3 years.

04 legacy sedan 188,000. normal maintenance. plugs and wires just now to try to fix this, but it did not work completly. sputter is gone, but Random!! loss of power no rpm change while depressing the gas pedal still occurring
thank you very much for any help you can offer