Does artificial intelligence write its own code and then execute it? If so, does it create separate functions for each purpose? How does learning get implemented in artificial intelligence?