import torch


def log_density(x: torch.Tensor) -> torch.Tensor:
    """Computes the density of points for a set of points

    Args:
        x (torch.Tensor): set of points (N x D)

    Returns:
        torch.Tensor: density in # points per unit of volume in the set
    """
    hypercube_min, _ = torch.min(x, dim=0)
    hypercube_max, _ = torch.max(x, dim=0)

    log_vol = torch.sum(torch.log(hypercube_max - hypercube_min), 0)
    return torch.log(torch.Tensor([x.shape[0]])) - log_vol