>>jrm4+(OP)
It depends. If names are different, character and plot details differ, etc., a book about students at a school for wizards battling great evil may be a not particularly imaginative rip-off and may even invite litigation if it's
too close, but I'm guessing it wouldn't win in court. See also The Sword of Shannara and Tolkien.
https://en.wikipedia.org/wiki/The_Sword_of_ShannaraCreators mimic styles and elements of others' works all the time. Unless an ML algorithm crosses some literal copying threshold, I fail to see it as doing anything substantially different from what people routinely do.