<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sync(self, bucket, delete_extras=False):
 """Sync self bucket ObjectVersions to the destination bucket. The bucket is fully mirrored with the destination bucket following the logic: * same ObjectVersions are not touched * new ObjectVersions are added to destination * deleted ObjectVersions are deleted in destination * extra ObjectVersions in dest are deleted if `delete_extras` param is True :param bucket: The destination bucket. :param delete_extras: Delete extra ObjectVersions in destination if True. :returns: The bucket with an exact copy of ObjectVersions in self. """

        assert not bucket.locked

        src_ovs = ObjectVersion.get_by_bucket(bucket=self, with_deleted=True)
        dest_ovs = ObjectVersion.get_by_bucket(bucket=bucket,
                                               with_deleted=True)
        # transform into a dict { key: object version }
        src_keys = {ov.key: ov for ov in src_ovs}
        dest_keys = {ov.key: ov for ov in dest_ovs}

        for key, ov in src_keys.items():
            if not ov.deleted:
                if key not in dest_keys or \
                        ov.file_id != dest_keys[key].file_id:
                    ov.copy(bucket=bucket)
            elif key in dest_keys and not dest_keys[key].deleted:
                ObjectVersion.delete(bucket, key)

        if delete_extras:
            for key, ov in dest_keys.items():
                if key not in src_keys:
                    ObjectVersion.delete(bucket, key)

        return bucket