def _compute_element_numbers(elements):
    """Build map from elements to element numbers."""
    element_numbers = {}
    for i, element in enumerate(elements):
        element_numbers[element] = i
    return element_numbers
