[(Exodus 31:18:) "And when He had finished speaking with him, He gave unto Moses."] Rabbi Abbahu said: All forty days that Moses spent on high, he would learn Torah and forget it. Moses said to Him: "Master of the Universe, here I have forty days, and I do not know a single thing!" What did the Holy One, blessed be He, do? When he had completed forty days, He gave him the Torah as a gift. "And He gave unto Moses."
Moses Learns and Forgets the Torah Until God Gives It as a Gift
Midrash Tanchuma Buber, Ki Tisa 12:1
[ויתן אל משה ככלותו]. אמר ר' אבהו כל ארבעים יום שעשה משה למעלה, היה לומד תורה ושוכחה, א"ל משה רבונו של עולם הרי יש לי מ' יום ואיני יודע שום דבר, מה עש הקב"ה כשהשלים מ' יום, נתן לו את התורה במתנה, ויתן אל משה.