def persistent_real_state(real_state, spike):
    """Handles refractory state changes due to spike in last time bin.

    Parameters
    ----------
    real_state : torch tensor
        real state in last time bin.
    spike : torch tensor
        spike state in last time bin.

    Returns
    -------
    torch tensor
        persistent real state to store for next time.
    """
    spike = (spike > 0).to(real_state.dtype)
    return real_state * (1 - spike)