def _max_weight_state(states: Iterable[value.ProductState]) -> value.ProductState | None:
    """Create a new state that is compatible with all input states
    and has the maximum weight.

    The returned TensorProductState is constructed by taking the
    single-qubit state at each qubit position.

    This function will return `None` if the input states are not compatible

    For example, the max_weight_state of [+X(0), -Z(1)] is
    "+X(0) * -Z(1)". Asking for the max weight state of something like
    [+X(0), +Z(0)] will return None.
    """
    qubit_state_map: dict[ops.Qid, _NamedOneQubitState] = {}
    for state in states:
        for qubit, named_state in state:
            if qubit in qubit_state_map:
                if qubit_state_map[qubit] != named_state:
                    return None
            else:
                qubit_state_map[qubit] = named_state
    return value.ProductState(qubit_state_map)
Create a new state that is compatible with all input states
    and has the maximum weight.

    The returned TensorProductState is constructed by taking the
    single-qubit state at each qubit position.

    This function will return `None` if the input states are not compatible

    For example, the max_weight_state of [+X(0), -Z(1)] is
    "+X(0) * -Z(1)". Asking for the max weight state of something like
    [+X(0), +Z(0)] will return None.
    
cirq-core/cirq/work/observable_settings.py