import torch


def entropic_loss(pnl) -> torch.Tensor:
    """
    Return entropic loss function, which is a negative of
    the expected exponential utility:

        loss(pnl) = -E[u(pnl)], u(x) = -exp(-x)

    Parameters
    ----------
    pnl : torch.Tensor, shape (*)
        Profit-loss distribution.

    Returns
    -------
    entropic_loss : torch.Tensor, shape (,)

    Examples
    --------
    >>> pnl = -torch.arange(4.0)
    >>> entropic_loss(pnl)
    tensor(7.7982)
    """
    return -torch.mean(-torch.exp(-pnl))