Bava Basra 15a
The Gemoro asks who wrote the last eight Pesukim in the Torah (וימת שם משה) and answers two Tirutzim.
The Zohar* has a third answer.
"Moshe was Niftar and Hashem brought him back to life. Moshe wrote then the last eight Pesukim, and died again."
The Malbim has a beautiful pshat on the Pasuk
“תורת ה' תמימה ”-The Torah is complete – “משיבת נפש”- because Hashem brought back the Nefesh of Moshe to write and complete the last eight
Pesukim in the Torah.
*With this Zohar we might be able to answer Tosfos (Menachos 30a) Kushya.
"How could Moshe have died Shabbos at Mincha time when that year the 7th
of Adar was on a Friday."
It is possible that Moshe died on Friday the 7th of Adar. He was brought back
to life and wrote the 13 Sifrei Toras on Friday. He died again on Shabbos the
8th of Adar.(אמבצי)