I read
https://docs.github.com/en/site-policy/github-terms/github-t...
Chapter D4 gives microsoft the right to: parse it into a search index or otherwise analyze it on our servers
I don't know what a real court says, but I can imagine a lawyer saying training an AI is done by analyzing your code.
Chapter D5 gives almost anybody right to do a lot with your code, including creating derived works, as long as it happens on github. If the AI training happens on their servers, I think you agreed to them training an AI.
Not saying they are doing it right now based on that document. But I do assume a lawyer has enough material to make the waters really muddy, and a trial being decide by basically a dice roll.