input: Write a python function to detect anagrams in a list of words.
  assert detect_anagrams(["canoe", "fez", "act", "cat"])==[['canoe'], ['act', 'cat']]
  assert detect_anagrams(["listen", "silent", "enlist", "google", "goggle"])==[['listen', 'silent', 'enlist'], ['google']]
  assert detect_anagrams(["star", "rats", "car", "arc", "arts"])==[['star', 'rats', 'arts'], ['car', 'arc']]
output: def detect_anagrams(words):
      from collections import defaultdict
      anagrams = defaultdict(list)
      
      for word in words:
          sorted_word = ''.join(sorted(word))
          anagrams[sorted_word].append(word)
      
      return [group for group in anagrams.values() if len(group) > 1 or len(group) == 1]