<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_current_head(graph):
 """ Get the current database head revision, if any. """

    session = new_session(graph)
    try:
        result = session.execute("SELECT version_num FROM alembic_version")
    except ProgrammingError:
        return None
    else:
        return result.scalar()
    finally:
        session.close()