import torch


def _sigmoid_cross_entropy_with_logits(logits, labels):
    """
    get the sigmoid cross entropy by calculating with logits and labels
    :param logits: predicted logits
    :param labels: ground truth labels
    :return: loss
    """
    loss = torch.clamp(logits, min=0) - logits * labels.type_as(logits)
    loss += torch.log1p(torch.exp(-torch.abs(logits)))
    return loss