code: def _collect_scopes(handlers, scopes, user, client):
      
      results = set()
  
      data = {'user': user, 'client': client}
  
      def visitor(scope_name, func):
          claim_names = func(data)
          # If the claim_names is None, it means that the scope is not authorized.
          if claim_names is not None:
              results.add(scope_name)
  
      _visit_handlers(handlers, visitor, 'scope', scopes)
  
      return results
docs: Get a set of all the authorized scopes according to the handlers.