<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set(self, reference, document_data, merge=False):
 """Add a "change" to replace a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.set` for more information on how ``option`` determines how the change is applied. Args: reference (~.firestore_v1beta1.document.DocumentReference):
 A document reference that will have values set in this batch. document_data (dict):
 Property names and values to use for replacing a document. merge (Optional[bool] or Optional[List<apispec>]):
 If True, apply merging instead of overwriting the state of the document. """

        if merge is not False:
            write_pbs = _helpers.pbs_for_set_with_merge(
                reference._document_path, document_data, merge
            )
        else:
            write_pbs = _helpers.pbs_for_set_no_merge(
                reference._document_path, document_data
            )

        self._add_write_pbs(write_pbs)