A tensor became a 'list' object

Hello,

I was trying to use a pretrained model “ProtBERT” on a dataset. I got this error message when the training was about to start.
“***/envu/step/lib/python3.9/site-packages/transformers/tokenization_utils_base.py”, line 756, in
self.data = {k: v.to(device=device) for k, v in self.data.items()}
AttributeError: ‘list’ object has no attribute ‘to’

However, the dataset has been converted to tensor already. Not sure why it became a ‘list’ object now. The class to prepare the dataset is here

I have been working on this for two days. Any suggestions would be highly appreciated. Thank you all!

And this is how I call the class and start training.