The AI image generator is revealed to be a lossy compression algorithm which can recall near-identical images to the ones it was trained with. Therefore, the software is conveying copyrighted works. If somebody gave you the model, they violated copyright in doing so. If somebody runs the model on a server, they violated copyright in transmitting the image to you. If you, the recipient of that copyrighted work, go on to redistribute it, you have also violated the copyright. I don't see any difference between these image generators and code generators.
Exact replicas are an issue. If you are using AI image generation to replicate the near exact image, then that's illegal. But nobody cares if you copy a nice code pattern from a GPL code and apply it to your own code base. In the same fashion nobody should care if you make an image in the same art style.
Inexact replicas are also an issue, otherwise there would be no issue with distributing MP3s of an Audio CD, as it's a lossy format that is only close to the original.
I suspect the courts will treat AI more like a "black box" - they won't care how or why your black box can perfectly play Metallica, only that it does.
Yes, and that's why I personally believe that the model itself should be considered a derived work of such code. But OP was specifically talking about "code patterns".