Validates that state's size is a power of 2, returning number of qubits.

def _validate_num_qubits(state: np.ndarray) -> int:
    """Validates that state's size is a power of 2, returning number of qubits.
    """
    size = state.size
    if size & (size - 1):
        raise ValueError('state.size ({}) is not a power of two.'.format(size))
    return size.bit_length() - 1