def gates_to_idx(gates, qregs):
sizes = [qr.size for qr in qregs.values()]<EOL>reg_idx = np.cumsum([<NUM_LIT:0>]+sizes)<EOL>regint = {}<EOL>for ind, qreg in enumerate(qregs.values()):<EOL><INDENT>regint[qreg] = ind<EOL><DEDENT>out = np.zeros(<NUM_LIT:2>*len(gates), dtype=np.int32)<EOL>for idx, gate in enumerate(gates):<EOL><INDENT>out[<NUM_LIT:2>*idx] = reg_idx[regint[gate[<NUM_LIT:0>][<NUM_LIT:0>]]]+gate[<NUM_LIT:0>][<NUM_LIT:1>]<EOL>out[<NUM_LIT:2>*idx+<NUM_LIT:1>] = reg_idx[regint[gate[<NUM_LIT:1>][<NUM_LIT:0>]]]+gate[<NUM_LIT:1>][<NUM_LIT:1>]<EOL><DEDENT>return out<EOL>
Converts gate tuples into a nested list of integers.

    Args:
        gates (list): List of (QuantumRegister, int) pairs
                      representing gates.
        qregs (dict): List of )QuantumRegister, int) tuples.

    Returns:
        list: Nested list of integers for gates.