def _deserialize_gateset_and_gate_durations(
    proto: v2.device_pb2.DeviceSpecification,
) -> tuple[cirq.Gateset, Mapping[cirq.GateFamily, cirq.Duration]]:
    """Deserializes gateset and gate duration from DeviceSpecification."""

    gates_list: list[GateOrFamily] = []
    gate_durations: dict[cirq.GateFamily, cirq.Duration] = {}

    for gate_spec in proto.valid_gates:
        gate_name = gate_spec.WhichOneof('gate')

        gate_rep = next((gr for gr in _GATES if gr.gate_spec_name == gate_name), None)
        if gate_rep is None:  # pragma: no cover
            warnings.warn(
                f"The DeviceSpecification contains the gate '{gate_name}' which is not recognized"
                " by Cirq and will be ignored. This may be due to an out-of-date Cirq version.",
                UserWarning,
            )
            continue

        gates_list.extend(gate_rep.supported_gates)
        for g in gate_rep.supported_gates:
            gate_durations[g] = cirq.Duration(picos=gate_spec.gate_duration_picos)

    # TODO(#5050) Add GlobalPhaseGate support

    return cirq.Gateset(*gates_list), gate_durations
Deserializes gateset and gate duration from DeviceSpecification.
cirq-google/cirq_google/devices/grid_device.py