code: def _to_pb(self):
          
          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)
docs: Construct a KeySet protobuf.
  
          :rtype: :class:`~google.cloud.spanner_v1.proto.keys_pb2.KeySet`
          :returns: protobuf corresponding to this instance.