The rate for Higgs ( H ) bosons production in association with either one ( tH ) or two ( tt¯H ) top quarks is measured in final states containing multiple electrons, muons, or tau leptons decaying to hadrons and a neutrino, using proton-proton collisions recorded at a center-of-mass energy of 13TeV by the CMS experiment. The analyzed data correspond to an integrated luminosity of 137 fb-1 . The analysis is aimed at events that contain H→WW , H→ττ , or H→ZZ decays and each of the top quark(s) decays either to lepton+jets or all-jet channels. Sensitivity to signal is maximized by including ten signatures in the analysis, depending on the lepton multiplicity. The separation among tH , tt¯H , and the backgrounds is enhanced through machine-learning techniques and matrix-element methods. The measured production rates for the tt¯H and tH signals correspond to 0.92±0.19(stat)-0.13+0.17(syst) and 5.7±2.7(stat)±3.0(syst) of their respective standard model (SM) expectations. The corresponding observed (expected) significance amounts to 4.7 (5.2) standard deviations for tt¯H , and to 1.4 (0.3) for tH production. Assuming that the Higgs boson coupling to the tau lepton is equal in strength to its expectation in the SM, the coupling yt of the Higgs boson to the top quark divided by its SM expectation, κt=yt/ytSM , is constrained to be within -0.9<κt<-0.7 or 0.7<κt<1.1 , at 95% confidence level. This result is the most sensitive measurement of the tt¯H production rate to date.