Interlayer interaction and optical properties of layer semiconductors: 2H and 4H polytypes of PbI2