[docs]defsigmoid_cross_entropy(logits:torch.Tensor,labels:torch.Tensor)->torch.Tensor:logits=logits.float()log_p=torch.nn.functional.logsigmoid(logits)log_not_p=torch.nn.functional.logsigmoid(-logits)# More numerically stable.loss=-labels*log_p-(1-labels)*log_not_preturnloss