The TL;DR is that training AI on copyrighted works falls under the Fair Use exemptions in copyright law
This judgement was reversed by the next federal judge that reviewed AI, in the Meta case.
It is far from legally settled whether training is fair use or not.