There are many open questions here. It is unclear that an LLM that has "seen" GPL code is a derived work of that code. Your brain can "see" GPL code without violating the license, even when you later write different code. Redistributing the GPL licensed code that was seen earlier is what would be most obviously infringing.
AI output is not copyrightable.
I am not a lawyer, but I'm wondering if the same argument can be made about derived works such as text - the AI is learning from open-source code, and outputting not the exact same code, but just 'derived' code based on patterns in the original code.
In other words, somewhat similar to what a programmer studying existing and open-source code would do: read the code, understand it, and try to reimplement by writing their own code.