Catalysis of the reaction: (E)-4-hydroxy-3-methylbut-2-en-1-yl diphosphate + NAD(P)H + H+ = isopentenyl diphosphate + NAD(P)+ + H2O. Note that (E)-4-hydroxy-3-methylbut-2-en-1-yl diphosphate is an alternative name for 1-hydroxy-2-methyl-2-(E)-butenyl 4-diphosphate.