Turn generated code into functions

Convert the Mito generated code into a Python function to make it even easier to reuse.

Last updated