import torch


def logsinh(x):
    """
    Compute log(sinh(x)), stably for large x.
    :param x : torch.tensor, argument to evaluate at, must be positive
    :return torch.tensor, log(sinh(x))
    """
    if torch.any(x < 0):
        raise ValueError("logsinh only valid for positive arguments")
    return x + torch.log(0.5 - torch.exp(-2 * x) / 2)