nodes: 0, module; 1, function_definition; 2, function_name:rank; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_default_parameter; 8, identifier:Counter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, return_statement; 13, identifier:words; 14, type; 15, identifier:exclude_stopwords; 16, type; 17, False; 18, comment:"""
      Sort words by frequency
  
      :param list words: a list of words
      :param bool exclude_stopwords: exclude stopwords
      :return: Counter
      """; 19, not_operator; 20, block; 21, identifier:exclude_stopwords; 22, block; 23, call; 24, generic_type; 25, identifier:bool; 26, identifier:words; 27, return_statement; 28, expression_statement; 29, identifier:Counter; 30, argument_list; 31, identifier:List; 32, type_parameter; 33, None; 34, assignment; 35, identifier:words; 36, type; 37, identifier:words; 38, list_comprehension; 39, identifier:str; 40, identifier:word; 41, for_in_clause; 42, if_clause; 43, identifier:word; 44, identifier:words; 45, comparison_operator:word not in _STOPWORDS; 46, identifier:word; 47, identifier:_STOPWORDS
code: def rank(words: List[str], exclude_stopwords: bool = False) -> Counter:
      """
      Sort words by frequency
  
      :param list words: a list of words
      :param bool exclude_stopwords: exclude stopwords
      :return: Counter
      """
      if not words:
          return None
  
      if exclude_stopwords:
          words = [word for word in words if word not in _STOPWORDS]
  
      return Counter(words)