You’d be committing career suicide by picking and choosing in those cases. You were legally safe and safe in terms of your job as well by punishing the whole class on the grounds that most of it was misbehaving.
I’m not saying this is right, but it is what we were taught. We’re not talking about corporal punishment – like the rest of my course, the lecturer completely ignored the existence of private schools – but any form that might be used.