I'd recommend taking a rescue class. I took one last year, and I'm no rescue diver now, but two things that the class really hammered in are 1) don't become a victim. That is covered pretty well in this thread already. Do not physically engage a panicked diver, but try to calm them down and provide assistance from at least 6 feet / 2 meters away, and orient your feet towards them so that you can quickly swim backwards when they come for you.
And 2) in-water rescue of a panicked diver is basically hand-to-hand combat. Ideally you do not physically engage at all with a panicked diver, but if you do, you must do whatever you can to gain control over the situation, because their actions can seriously harm or kill you. Grab their right wrist with your right hand, pull hard to spin them around, and grab their 1st stage with your left hand. That will keep their face and arms away from you. If they need it, get them a working reg with your right hand. Then put their the 1st stage to your right hand, and get control of their inflator with your left hand. Fan your fins out to slow the ascent.
We practiced this in class, and the spin maneuver was surprisingly effective. I'm somewhat confident that it would work, even if the victim outweighs me by 100 lbs / 45 kg. I have less confidence that I would be able to maintain control of the situation from there, but it's a start.
Edit to add: to directly answer the OP, in this situation I would try to yank the reg out of their mouth and let them go. If I couldn't do that, I would dump my inflator, fan my fins out, and keep breathing. I say this, of course, while sitting dry and on my couch on a sunny day with a cup of tea. Real-life, who the hell knows what would happen, but that would be my aspirational plan.