<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def replace_one(cls, filter, replacement, upsert=False):
 """ Replaces a document that passes the filter. Will upsert a new document if upsert=True and no document is filtered """

        return cls.collection.replace_one(
            filter, replacement, upsert
        ).raw_result