Defend yourself to get away is my policy. So, if there's no alternative and the only thing you can do is engage, engage. That also means don't fight words with fists, don't fight a slap with fists. Your reaction/defense can't be greater than the offense. And also to be considered is nothing comes from nowhere. Have you exhausted all means of intervention prior to it getting to the point of a fight? Is school staff not assisting? Are parents not doing anything? Has any higher authority been alerted? If the system where you are isn't trash, this can sometimes be nipped in the bud or avoided.
Intervening on someone's behalf? You'll have seconds to decide if that's more appropriate than getting an authority figure to intervene, but sometimes someone stepping up is enough to make some people stand down.
Is pride/ego the reason for the fight? Not letting someone "punk" you or being embarrassed? Because that's not a reason to engage, tbh.
You need to consider that people these days are different. Your beating someone down (regardless of a reason) can turn into a school shooting, school stabbing, family (grown people, in the case of minor schooling) coming to "assist" their loved one that you "defeated," and so on. I live somewhere where while school shootings like "the stories" aren't the norm, gang violence is (they just classify them differently since it's not someone coming to intentionally shoot up a school as much as gang retaliation type stuff). It's sadly not completely unheard of for parents or other family to roll up on a school and fight kids, etc. So, there are other factors to consider.
Last thing I wanted to mention, also, is that people, kids and adults, are very like pack animals. It's rarely gonna be a one-on-one thing, whether you're the intended target or stepping in for someone else (which invites more people). One-on-one honor fights from the past are gone. You're more likely to get ganged up on and stomped or something in most places. So, if you engage, know that's a possibility and know that help can be a long time coming... especially since most places don't want anyone, teachers or officers, being hands-on with violent students, and teachers esp. have been told to be hands-off on students, so you are just gonna be getting beat.
TLDR: My opinion is don't FAFO and defend yourself if your life is in danger.