I ignored adding the function and this line -https://github.com/huggingface/transformers/blob/bf713cdec7c27416f514f231ba6728cfc8135120/examples/language-modeling/run_clm.py#L310 261. I skipped it because i was using a very small dataset. It works now! Thank you so much for your help!