Transfer function that implements a “latching” mechanism in one of two variants,
depending on the value of the parameter keep_value.
If keep_value is zero: All states start at zero. If the input to a unit is
negative, set the state to low_value; if the input to a unit is positive,
set the state to high_value; otherwise, copy the previous state.
If keep_value is non-zero: All states start at zero. If the input to a unit
is non-zero, copy the input to the state; otherwise, copy the previous state.
parameter default_value keep_value 0 low_value -1 high_value 1