human
Can you provide a the Python code you requested given the following:
Complete the below
def _detach_db_obj(func):

    ''''Decorator to detach db_obj from the session.'
    '''
assistant
#Here is the Python code you requested.
    @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