Generates Google Random Circuits v2 in Bristlecone.
    See also https://arxiv.org/abs/1807.10749

    Args:
        n_rows: number of rows in a Bristlecone lattice.
          Note that we do not include single qubit corners.
        cz_depth: number of layers with CZ gates.
        seed: seed for the random instance.

    Returns:
        A circuit with given size and seed.

def generate_supremacy_circuit_google_v2_bristlecone(n_rows: int,
                                                     cz_depth: int, seed: int
                                                     ) -> circuits.Circuit:
    """
    Generates Google Random Circuits v2 in Bristlecone.
    See also https://arxiv.org/abs/1807.10749

    Args:
        n_rows: number of rows in a Bristlecone lattice.
          Note that we do not include single qubit corners.
        cz_depth: number of layers with CZ gates.
        seed: seed for the random instance.

    Returns:
        A circuit with given size and seed.
    """
    def get_qubits(n_rows):
        def count_neighbors(qubits, qubit):
            """Counts the qubits that the given qubit can interact with."""
            possibles = [
                devices.GridQubit(qubit.row + 1, qubit.col),
                devices.GridQubit(qubit.row - 1, qubit.col),
                devices.GridQubit(qubit.row, qubit.col + 1),
                devices.GridQubit(qubit.row, qubit.col - 1),
                ]
            return len(list(e for e in possibles if e in qubits))

        assert 1 <= n_rows <= 11
        max_row = n_rows - 1
        dev = google.Bristlecone
        # we need a consistent order of qubits
        qubits = list(dev.qubits)
        qubits.sort()
        qubits = [q for q in qubits
                      if  q.row <= max_row and  q.row + q.col < n_rows + 6
                      and q.row - q.col < n_rows - 5]
        qubits = [q for q in qubits if count_neighbors(qubits, q) > 1]
        return qubits

    qubits = get_qubits(n_rows)
    return generate_supremacy_circuit_google_v2(qubits, cz_depth, seed)