import torch


def sigmoid(dt2: torch.Tensor, sigma2: float) -> torch.Tensor:
    """Sigmoidal rasterisation function.
    
    Computes $$2 \\times \\sigmoid(-dt^2 / \\sigma)$$ giving values near 1.0
    for points in the distance transform with near-zero distance, and falling
    off as distance increases.

    Args:
      dt2: the squared distance transform
      sigma2: the rate of fall-off. Larger values result in greater line width,
              but also larger gradient flow across the raster

    Returns:
      the rasterised image

    """
    return torch.sigmoid(-1 * dt2 / sigma2) * 2.