def METHOD_NAME(x: Tensor) -> Tensor:
    """Similar to `_bincount`, but works also with tensor that do not contain continuous values.
    Args:
        x: tensor to count
    Returns:
        Number of occurrences for each unique element in x
    """
    # make sure elements in x start from 0
    x = x - x.min()
    unique_x = torch.unique(x)
    output = _bincount(x, minlength=torch.max(unique_x) + 1)  # type: ignore[arg-type]
    # remove zeros from output tensor
    return output[unique_x]