Can't figure out how to use pwm with an optocoupler and a MOSFET

How are resistors (R2 and R3 ) chosen for mosfets? How are they calculated?