Fine tune MarianMT for en to de error: in Dataloader when using data collator in collate_fn argument of data loader

I have been trying to fine-tune MarianMT for English to German on a custom dataset that I have. I want to fine-tune it using the native PyTorch approach in python. But when I try to load the dataset in PyTorch’s Dataloader and iterate over it to print a batch, I get the following error: unsupported operand type(s) for +: ‘Tensor’ and ‘list’. I have attached the snap of the error that I got.


I have followed the procedure of fine-tuning the model from https://huggingface.co/course/chapter3/4?fw=pt making suitable changes according to the requirements of the model. Another reference that I have used from here: https://huggingface.co/transformers/notebooks.html
The error does not occur when I do not pass the DataCollatorForSeq2Seq in Dataloader.
Checkpoint used = Helsinki-NLP/opus-mt-en-de
Thank You!