def total_error_to_per_piece_error(error_rate: float, pieces: int) -> float:
    """Convert from total error rate to per-round error rate."""
    if error_rate > 0.5:
        return 1 - total_error_to_per_piece_error(1 - error_rate, pieces)
    assert 0 <= error_rate <= 0.5
    randomize_rate = 2*error_rate
    round_randomize_rate = 1 - (1 - randomize_rate)**(1 / pieces)
    round_error_rate = round_randomize_rate / 2
    return round_error_rate