If your target is a probability between 0 and 1, you could directly use it in nn.BCEWithlogitsLoss.
You don’t need to apply a threshold on the model output to calculate the loss, but could use it to get the predictions and calculate the accuracy.
If your model outputs are logits, you could use a threshold of 0.0.