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".