human
Complete this python program:
def _detach_db_obj(func):
assistant
#Here is the Python program you requested.

    """Decorator to detach db_obj from the session.
    """
    @functools.wraps(func)
    def decorator(self, *args, **kwargs):
        synthetic_changed = bool(self._get_changed_synthetic_fields())
        res = func(self, *args, **kwargs)
        if synthetic_changed:
            self.obj_context.session.refresh(self.db_obj)
        self.obj_context.session.expunge(self.db_obj)
        return res
    return decorator