VARIATIONS OF THE STELLAR INITIAL MASS FUNCTION IN THE PROGENITORS OF MASSIVE EARLY-TYPE GALAXIES AND IN EXTREME STARBURST ENVIRONMENTS