def internal_gate_from_proto(msg: v2.program_pb2.InternalGate) -> InternalGate:
    """Extracts an InternalGate object from an InternalGate proto.

    Args:
        msg: The proto containing a serialized value.

    Returns:
        The deserialized InternalGate object.

    Raises:
        ValueError: On failure to parse any of the gate arguments.
    """
    gate_args = {}
    for k, v in msg.gate_args.items():
        gate_args[k] = arg_from_proto(v)
    return InternalGate(
        gate_name=str(msg.name),
        gate_module=str(msg.module),
        num_qubits=int(msg.num_qubits),
        custom_args=msg.custom_args,
        **gate_args,
    )
Extracts an InternalGate object from an InternalGate proto.

    Args:
        msg: The proto containing a serialized value.

    Returns:
        The deserialized InternalGate object.

    Raises:
        ValueError: On failure to parse any of the gate arguments.
    
cirq-google/cirq_google/serialization/arg_func_langs.py