miners choose a value for generated_value, hash it and hope it comes out with the required number of zeros, if not they try again, and again, and again until they (or someone else) finds a value.
for simplicity let's say the fn(x) = x.
difficulty of 5? hash must have 5 zeros at the beginning: 00000XXXXXXXXXXXXXXXXXXXXXXXXX
10? must have 10: 0000000000XXXXXXXXXXXXXXXXXXXX
each zero you add on requires exponentially more time.