Atomic theory of viscoelastic response and memory effects in metallic glasses