code: def get_session(account_info):
      
      s = getattr(CONN_CACHE, '%s-session' % account_info['name'], None)
      if s is not None:
          return s
      if account_info.get('role'):
          s = assumed_session(account_info['role'], SESSION_NAME)
      else:
          s = boto3.Session()
      setattr(CONN_CACHE, '%s-session' % account_info['name'], s)
      return s
docs: Get a boto3 sesssion potentially cross account sts assumed
  
      assumed sessions are automatically refreshed.