Sampling rare events across dynamical phase transitions.