def serialize(
        self, program: cirq.AbstractCircuit, msg: v2.program_pb2.Program | None = None
    ) -> v2.program_pb2.Program:
        """Serialize a Circuit to cirq_google.api.v2.Program proto.

        Args:
            program: The Circuit to serialize.
            msg: An optional proto object to populate with the serialization
                results.

        Raises:
            NotImplementedError: If the program is of a type that is supported.
        """
        if not isinstance(program, (cirq.Circuit, cirq.FrozenCircuit)):
            raise NotImplementedError(f'Unrecognized program type: {type(program)}')
        raw_constants: dict[Any, int] = {}
        if msg is None:
            msg = v2.program_pb2.Program()
        msg.language.gate_set = self.name
        # Arg function language is no longer used, but written for backwards compatibility.
        msg.language.arg_function_language = 'exp'
        self._serialize_circuit(
            program, msg.circuit, constants=msg.constants, raw_constants=raw_constants
        )
        return msg
Serialize a Circuit to cirq_google.api.v2.Program proto.

        Args:
            program: The Circuit to serialize.
            msg: An optional proto object to populate with the serialization
                results.

        Raises:
            NotImplementedError: If the program is of a type that is supported.
        
cirq-google/cirq_google/serialization/circuit_serializer.py