def export(self) -> proto.MIL_pb2.Program:
        """
        Export a pymil program into mil proto with the given specification version.
        """
        if BlobWriter is None:
            raise RuntimeError("BlobWriter not loaded")

        function_protos = {}
        for func_name, func in self.prog.functions.items():
            function_protos[func_name] = self.convert_function(
                func, _OPSET[self.specification_version]
            )

        kwargs = {
            "version": 1,
            "functions": function_protos,
        }

        prog_attributes = self.translate_program_attributes()
        if len(prog_attributes) > 0:
            kwargs["attributes"] = prog_attributes

        return proto.MIL_pb2.Program(**kwargs)

        Export a pymil program into mil proto with the given specification version.
        
coremltools/converters/mil/backend/mil/load.py