You can remain in the UK under your Tier 4 visa until the date of completion of studies according to your CAS with an additional period up to 4 months to allow you time to complete any arrangements e.g Graduation, re-sits, looking for sponsored employment. If you return to your home country during this period you are strongly advised that UKVI may cancel any remaining time on your visa and you may be refused re-entry to the UK on arrival.
If your Tier 4 visa does not allow you to remain in the UK for your Graduation (within the period following completion of studies) you will be required to return to your home country and apply for a Standard Visitor visa to re-enter the UK. VISA can advise on the process and documents required. The fee is £93.
With the Standard Visitor visa you can stay in the UK for up to six months but you are not allowed to work (paid or unpaid) at any time. You can apply for this visa up to 3 months before your date of travel to the UK. You should get a decision for your visa within 3 weeks, but this may take longer at busy periods.
If you are required to return to resit exams or re-submit coursework you should apply for a Short-Term Study visa.