What is the condition of the number of targets you can batch?
Sufficient data left for the batch_size?
If so, you could try the following code snippet and extend it to your use case:
class MyDataset(Dataset):
    def __init__(self, X, y):
        self.data = X
        self.target = y
        
    def __getitem__(self, index):
        x = self.data[index]
        y = self.target[index]
        
        return x, y
    
    def __len__(self):
        return len(self.data)


# Create fake data
X = torch.randn(100, 3, 16, 16)
y = torch.Tensor(100).random_(0, 10).long()

dataset = MyDataset(X, y)

loader = DataLoader(dataset,
                    batch_size=6,
                    num_workers=1,
                    shuffle=False,
                    drop_last=False)


for data, target in loader:
    # Your training procedure...
    print data.shape
    print target.shape


If you set  batch_size=5, all batches will have 5 samples in them, since 100 is dividable by 5 without a remainder.
Keeping batch_size=6 will give you batches of size 6 apart from the last one, which will have 4 samples, if drop_last is set to False.
Try to play around with num_workers so that your DataLoader will use multi-processing.