I already did that. My code was working either age or gender individually, but when I try to run as multioutput, it keeps showing this error.
Here is my CustomDataset
class Data(Dataset):
    
    def __init__(self, csv_file, root_dir, transform):
        self.csv_file = pd.read_csv(csv_file)
        self.root_dir = root_dir
        self.transform = transform
        
    def __len__(self):
        return len(self.csv_file)
    
    def __getitem__(self, idx):
        if torch.is_tensor(idx):
            idx = idx.tolist()
            
        img_name = os.path.join(self.root_dir, 
                                self.csv_file.iloc[idx, 0])
        image = Image.open(img_name).convert('RGB')
        label_age = self.csv_file.iloc[idx, 1]
        label_gender = self.csv_file.iloc[idx, 2]
        
        if self.transform:
            image = self.transform(image)
            
        return {
            'image': image,
            'label_age': label_age,
            'label_gender': label_gender
        }

And the training part
def train_model(model, criterion1, criterion2, optimizer, scheduler, n_epochs=10):
    """return trained model"""
    # initialize tracker for minimum validation loss
    valid_loss_min = np.Inf
    print('Training started')
    for epoch in range(1, n_epochs):
        start_time = time.monotonic()
        train_loss = 0.0
        valid_loss = 0.0
        # train the model
        model.train()
        for idx, batch in enumerate(train_loader):
            # get data and move to GPU
            image, label1, label2 = batch['image'].to(device), batch['label'].to(device)
            # zero the parameter gradients
            optimizer.zero_grad()
            output = model(image)
            label1_hat = output['label1']
            label2_hat = output['label2']
            # calculate loss
            loss1 = criterion1(label1_hat, label1.squeeze().type(torch.LongTensor))
            loss2 = criterion2(label2_hat, label2.squeeze().type(torch.LongTensor))
            loss = loss1 + loss2
            # backprop
            loss.backward()
            # grad
            optimizer.step()
            scheduler.step()
            train_loss = train_loss + ((1 / (idx + 1)) * (loss.data - train_loss))
            if idx % 50 == 0:
                print('Epoch %d, Batch %d loss: %.6f' % (epoch, idx + 1, train_loss))
                
        # validate the model 
        model.eval()
        for idx, batch in enumerate(valid_loader):
            # get data and move to GPU
            image, label1, label2 = batch['image'].to('cuda'), batch['label_age'].to('cuda'), batch['label_gender'].to('cuda')
            output = model(image)
            label1_hat = output['label1']
            label2_hat = output['label2']
            # calculate loss
            loss1 = criterion1(label1_hat, label1.squeeze().type(torch.LongTensor))
            loss2 = criterion2(label2_hat, label2.squeeze().type(torch.LongTensor))
            loss = loss1 + loss2
            valid_loss = valid_loss + ((1 / (idx + 1)) * (loss.data - valid_loss))
            
            end_time = time.monotonic()
            epoch_mins, epoch_secs = epoch_time(start_time, end_time)
            print('#################################################')
            print(f'Epoch: {epoch} | Epoch Time: {epoch_mins}m {epoch_secs}s')
            # print training/validation statistics
            for param_group in optimizer.param_groups:
                print("Current learning rate is: {}".format(param_group['lr'])) 
            print('Epoch: {} \tTraining Loss: {:.6f} \tValidation Loss: {:.6f}'.format(epoch, train_loss, valid_loss))
            
            # save the model if validation loss has decreased
            if valid_loss < valid_loss_min:
                torch.save(model, 'model.pt')
                print('Validation loss decreased ({:.6f}) --> {:.6f}. Saving model ...'.format(valid_loss_min, valid_loss))
                valid_loss_min = valid_loss
        # return trained model
        return model