def intersection_count_to_boundary_weight(intersection_count: int) -> int:
    """
    Get actual weight factor for boundary intersection count.

    >>> intersection_count_to_boundary_weight(2)
    0
    >>> intersection_count_to_boundary_weight(0)
    1
    >>> intersection_count_to_boundary_weight(1)
    2
    """
    if not isinstance(intersection_count, int):
        intersection_count = intersection_count.item()
    assert isinstance(intersection_count, int)
    if intersection_count == 0:
        return 1
    if intersection_count == 1:
        return 2
    if intersection_count == 2:
        return 0
    raise ValueError(f"Expected 0,1,2 as intersection_count. Got: {intersection_count}")