Small-polaron formation and optical absorption in Su-Schrieffer-Heeger and Holstein models