In our private schools, we simply swap out the teachers. In such schools where the teacher cannot be changed, one can ask an assistant to sit in, or send the teacher on more training courses.
A teacher is to train students, and part of that is making the students respect education enough to sit down and listen. If the teacher can't do that, then sorry, but that's not a good teacher. If the teacher realises that a particular class constellation does not work, then he or she should do something about it, not blame an invisible 'system'.