I am only trying to do this because my dataset is unbalanced and I want the loss function to take that into consideration…
Im not even sure what input is, from what I understand it is the data from the training data loader, if the so, it should have a labels  field, seeing I defined it as follows
import torch 

class SequenceDataset(torch.utils.data.Dataset):
    def __init__(self, encodings, labels):
        self.encodings = encodings
        self.labels = labels
        
    def __getitem__(self, idx):
        item = {key: torch.tensor(val[idx]) for key, val in self.encodings.items()}
        item['label'] = torch.tensor(self.labels[idx])
        return item
    
    def __len__(self):
        return len(self.labels)

I see you run into the same issue in the end of this notebook 3. Did you find a solution?