<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _to_pb(self):
 """Construct a KeySet protobuf. :rtype: :class:`~google.cloud.spanner_v1.proto.keys_pb2.KeySet` :returns: protobuf corresponding to this instance. """

        if self.all_:
            return KeySetPB(all=True)
        kwargs = {}

        if self.keys:
            kwargs["keys"] = _make_list_value_pbs(self.keys)

        if self.ranges:
            kwargs["ranges"] = [krange._to_pb() for krange in self.ranges]

        return KeySetPB(**kwargs)