You have to create an object of the criterion first and later call it with your tensors.
Change:
loss = nn.BCEWithLogitsLoss(outputs, targets)

to
criterion = nn.BCEWithLogitsLoss()
for data in loader:
    ...
    loss = criterion(output, target)
    loss.backward()