Optical implementation of spin squeezing