The car will be running correctly and suddenly will not accelerate. on 2000 Mercedes-Benz E320 4MATIC

I can be on the street or freeway and suddenly I can't accelerate even if I have the pedal all the way to the floor.
This has happened twice in one day, it's sporadic and if I turn off the car for a while it's fine for a bit then suddenly
it occurs again. Is it the engine or transmission