def qubit_to_proto_id(q: cirq.Qid) -> str:
    """Return a proto id for a `cirq.Qid`.

    For `cirq.GridQubit`s this id `{row}_{col}` where `{row}` is the integer
    row of the grid qubit, and `{col}` is the integer column of the qubit.

    For `cirq.NamedQubit`s this id is the name.

    For `cirq.LineQubit`s this is string of the `x` attribute.

    For `cirq_google.Coupler`s, this id is `c_{qubit0}_{qubit1}` where
    qubit0 and qubit1 are the ids for the two Qid in the Coupler.
    """
    if isinstance(q, cirq.GridQubit):
        return f'{q.row}_{q.col}'
    elif isinstance(q, cirq.NamedQubit):
        return q.name
    elif isinstance(q, cirq.LineQubit):
        return f'{q.x}'
    elif isinstance(q, Coupler):
        return f'c_{qubit_to_proto_id(q.qubit0)}_{qubit_to_proto_id(q.qubit1)}'
    else:
        raise ValueError(f'Qubits of type {type(q)} do not support proto id')
Return a proto id for a `cirq.Qid`.

    For `cirq.GridQubit`s this id `{row}_{col}` where `{row}` is the integer
    row of the grid qubit, and `{col}` is the integer column of the qubit.

    For `cirq.NamedQubit`s this id is the name.

    For `cirq.LineQubit`s this is string of the `x` attribute.

    For `cirq_google.Coupler`s, this id is `c_{qubit0}_{qubit1}` where
    qubit0 and qubit1 are the ids for the two Qid in the Coupler.
    
cirq-google/cirq_google/api/v2/program.py