The functions pre_apply(), apply() and post_apply() are used to generate a new Experiment.py on the fly for each quantum circuit in PennyLane. apply() loops through the operations in the circuit while the other functions always write the same necessary code for the compilation.