import math
import torch


def inv_softplus(x):
    """ Inverse softplus function: Maps x lying in (0, infty) to R"""
    if isinstance(x, float):
        return math.log(math.exp(x) - 1)
    else:
        return torch.log(torch.exp(x) - 1)