Take a look at the prompts people use in these examples. They are always so contrived. Sure if you ask it to "Take this function exactly as it is from this file at this repo and output it without changes" it can do that.
My brain contains loads of copyrighted info. And if I exactly reproduce it from memory, it's copyright infringement. But if I come up with my own work, even if using that copyrighted info to learn from, it isn't infringement.