def _pairs_from_moment(moment: cirq.Moment) -> list[QidPairT]:
    """Helper function in `get_random_combinations_for_layer_circuit` pair generator.

    The moment should contain only two qubit operations, which define a list of qubit pairs.
    """
    pairs: list[QidPairT] = []
    for op in moment.operations:
        if len(op.qubits) != 2:
            raise ValueError("Layer circuit contains non-2-qubit operations.")
        pairs.append(op.qubits)
    return pairs
Helper function in `get_random_combinations_for_layer_circuit` pair generator.

    The moment should contain only two qubit operations, which define a list of qubit pairs.
    
cirq-core/cirq/experiments/random_quantum_circuit_generation.py