Intermolecular potential and width of pressure broadened spectral lines. IV. Influence of the nonrigidity of the molecules; diatomic molecules case