Deep importance sampling using tensor trains with application to a priori and a posteriori rare event estimation