import torch


def hard_sigmoid(tensor: torch.Tensor, inplace: bool = False) -> torch.Tensor:
    """
    Applies HardSigmoid function element-wise.

    See :class:`torchlayers.activations.HardSigmoid` for more details.

    Arguments:
        tensor :
            Tensor activated element-wise
        inplace :
            Whether operation should be performed `in-place`. Default: `False`

    Returns:
        torch.Tensor:
    """
    return torch.nn.functional.hardtanh(tensor, min_val=0, inplace=inplace)