torch.nn.functional.binary_cross_entropy_with_logits() is a function which will calculate the loss directly:
torch.nn.functional.binary_cross_entropy_with_logits(logits, label)
whereas nn.BCEWithLogitsLoss() initiates a class first and calls torch.nn.functional.binary_cross_entropy_with_logits() when forward is called:
criterion = torch.nn.BCEWithLogitsLoss(pos_weight=pos_weight)
criterion(output, target)
For more detailed explanations on the differences between torch.nn and torch.nn.functional, checkout this thread here.