How to create a generator function?

I have learned that Generator functions are a powerful tool in Python for generating sequences of values on-the-fly, without having to precompute and store them all in memory. But I don’t know exactly how I code generator functions and how they work. Are there any libraries available that help us to create generator functions? Can someone help me with code that shows exactly how generator functions in Python create and work?