Inverse Design and Automatic Differentiation for Optical Devices