Where I trained, large community hospital with unopposed program, FM residents run the codes (CPR, stroke, pediatric), intubates, place lines. ER attendings and anesthesia attendings serve as back up. 24 hour in-house Neo attendings runs neonatal codes with FM resident assisting. Intraop codes are unheard of, but codes do happen in the PACU. ER attendings runs their own codes, but they do activate the code to call on all the techs, nurses, pharmacists, administration, and chaplain.
Residents will step aside when the private attendings seem to know what they're doing, but usually the private attendings will flee. Because residents run the codes, most community docs are out of practice anyways. The exception are Pulm/CC, ER, and CV surgery attendings. Some of the community cardiologists are good, others not so much. Anesthesia are adept at the procedures, but you can tell they're out of practice. CV surgeons have the most awesome codes when they pop their sternotomy wires and stick their hands into the patient's chest and massage the heart (of course, they almost always die). Yea, we usually step aside on that one, thanks.
At another smaller community hospital where we work but don't take in-house call, the ER docs are the only ones around, so they run upstairs to run the codes.