To regain your immigration eligibility for CPT or OPT, you are required to be enrolled as a full-time student for at least two semesters (fall/spring) upon your return to the U.S.
Summer does not count as a semester for this purpose.
If you have exactly two (2) semesters left once you return, you can apply and be authorized for final semester Reduced Course Load (RCL) on your second and final semester if you have fewer credits left to take. In this scenario, you will regain your immigration eligibility for Post-completion Optional Practical Training (OPT) at the end of your second semester.
If you have only one (1) semester left upon your return, you won’t be eligible to apply for Post-completion Optional Practical Training (OPT).