def _serialize_config(config):
    """Turns a config into an integer treating each of the variables as spins.

    Examples:
        >>> _serialize_config((0, 0, 1))
        1
        >>> _serialize_config((1, 1))
        3
        >>> _serialize_config((1, 0, 0))
        4

    """
    out = 0
    for bit in config:
        out = (out << 1) | (bit > 0)

    return out