A federal judge says training AI on copyrighted works is ‘fair use,’ but casts doubt on use of pirated materials