Surging like that is almost always related to carb adjustment and governor adjustment. It can also be caused by fuel blockage in the supply lines though which usually happens under heavy engine load.
Check for cleanliness, wear, and proper adjustment.
If your engine is only surging at high rpm I would suspect a fuel blockage in the tank or a line or something of that nature. This would be the first thing to check.
If your engine is surging eradically and at all engine rpms/load conditions then I would suspect the governor/carb adjustment.
I can't recall off the top of my head which style governor the 5000 has but almost all governors work off tension balanced by engine demand.
The tension is supplied by centrifigal force using a fly weight assembly or by an actual spring.
If it has a flyweight assembly check for wear on the weights and general sloppiness of the assembly.
If everything looks good then its likely your carb just needs some cleaning and tuning.
Also make sure your ignition timing is correct and isnt bouncing all over the place (worn distributor parts).
Make sure your carb and governor is getting all the fuel it needs before messing with them.
Tank, lines, fuel pump for blockage or problems is the first place to start.
I had an old detroit 6-71 that was giving me fits once with surging under load at high rpm.
Drop it back to idle and it purred like a kitten.
2 days later I finally narrowed the problem down to the rubber lining that was used in the gas tank. A small part of it near the fuel outlet fitting had partway come lose from the tank so it was acting like a little flapper valve over the tank outlet.
Suction wasnt enough at low rpm to peal this flapper up but as soon as fuel demand increased so did the suction and the little flapper flipped over and blocked the fuel hole lol.
I own one of these fine tractors. Mine was doing the same thing and it was the distributor worn out. GOOD LUCK finding one. My governor was also worn but seems to be ok. If it turns out to be the dist and you cant find one let me know and I will give you the info on where I got mine ( reman) JHH.
do you have enough fuel in it to run? i know that sounds silly, but we have an older ford pickup with broken fuel gauges and we know when we are right down to the bottom when we get power surges. also does it in tractor. just something else to think about.