def _one_for_each_state(value, n_states: int, name: str) ->list:
    """Duplicate a value for each initial state if there is only one value."""
    if isinstance(value, (tuple, list)):
        if len(value) != n_states:
            raise ValueError(
                f"When `{name}' is a list or tuple, it must contain exactly as many values as initial states of the underlying RNN. Expected: {n_states}, got: {len(value)}"
                )
    else:
        value = [value] * n_states
    return value
