input: Write a python function to detect anagrams from a given list of words.
  assert detect_anagrams(['dog', 'bar', 'home', 'god', 'act', 'chair']) == [['dog', 'god']]
  assert detect_anagrams(['listen', 'silent', 'enlist', 'inlets', 'google', 'gogole']) == [['listen', 'silent', 'enlist', 'inlets'], ['google', 'gogole']]
  assert detect_anagrams(['cat', 'tac', 'act', 'bat', 'tab', 'rat']) == [['cat', 'tac', 'act'], ['bat', 'tab']]
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]