I only now understand that you are mix-and-matching self() and self.model(). This seems a question that pertains to PyTorch Lightning and not Transformers. Better to ask the people over there, specifically how their loss function is implemented and - importantly - how they reshape the labels and outputs.