Time dependent loss reweighting for flow matching and diffusion models is theoretically justified