def get_session(monitored_sess):
    """ Get Session object from MonitoredTrainingSession.
    """
    session = monitored_sess
    while type(session).__name__ != 'Session':
        session = session._sess

    return session