I don’t know if this is done in practice, but if you have a nuclear powered sub, implementing a water electrolyzer that makes oxygen is fairly trivial. Then you have air as long as you have power, so they could in principle stay submerged for ≈ 20 years, or however long the nuclear reactors can go without refill.