def _get_active_pairs(graph: nx.Graph, grid_layer: GridInteractionLayer):
    """Extract pairs of qubits from a device graph and a GridInteractionLayer."""
    for edge in graph.edges:
        if edge in grid_layer:
            yield edge
Extract pairs of qubits from a device graph and a GridInteractionLayer.
cirq-core/cirq/experiments/random_quantum_circuit_generation.py