input: Write a function to find all anagrams in a list of words.
  assert anagrams(["ab","ba","dog","god"]) == [['ab', 'ba'], ['ba', 'ab'], ['dog', 'god'], ['god', 'dog']]
  assert anagrams(["listen","silent","enlist","hello"]) == [['listen', 'silent'], ['listen', 'enlist'], ['silent', 'listen'], ['silent', 'enlist'], ['enlist', 'listen'], ['enlist', 'silent']]
  assert anagrams(["abc","def","ghi"]) == []
output: def anagrams(words):
      from collections import defaultdict
      anagram_map = defaultdict(list)
      
      for word in words:
          sorted_word = ''.join(sorted(word))
          anagram_map[sorted_word].append(word)
      
      result = []
      for anagram_list in anagram_map.values():
          if len(anagram_list) > 1:
              for i in range(len(anagram_list)):
                  for j in range(len(anagram_list)):
                      if i != j:
                          result.append([anagram_list[i], anagram_list[j]])
                          
      return result