Not saying it's ethical, but a lawyer friend of mine claims that there are numerous ways to get around a "training contract"
I don't know if, when it came down to it, they would actually try to enforce it (meaning lawyers, courts, etc). I'm guessing it is primarily a deterrent to people leaving right away. But just like other have said, you'd probably only be leaving for a job where you could afford to pay it if you needed to.