When I use DataParalle, I find the first dim of outputs is batch_size * gpu_nums, and when I calculate the loss, the error coming

ValueError:  Expected input batch_size (32) to match target batch_size (16).

my code is:

model = DataParallel(model, device_ids=gpus, output_device=gpus[0])
model.to(config.cuda_id)
outputs = model(input_ids, token_type_ids, attention_mask)
loss = loss_fct(outputs, labels.cuda(config.cuda_id))

I think the first dim of outputs should be batch_size
How to fix this, anybody can help me? thx