input: Write a function that determines if two input strings are anagrams. Two strings are considered anagrams if they contain the same characters with the same frequencies. If the strings are anagrams, the function should return True, otherwise it should return False. The function should first check if the lengths of the two strings are equal. If not, it should return False immediately. If they are the same length, it should count the frequency of each character in both strings and compare them.
  
  def is_anagram(str1, str2):
      if len(str1) != len(str2):
          return False
      
      str1_counts = collections.Counter(str1)
      str2_counts = collections.Counter(str2)
      
      for char in str1_counts:
          if str1_counts[char] != str2_counts[char]:
              return False
              
      return True
  
  assert is_anagram("abcd", "cbda") == True
  assert is_anagram("abcd", "abce") == False
  assert is_anagram("silent", "listen") == True
  assert is_anagram("triangle", "integral") == True
output: def is_anagram(str1, str2):
      if len(str1) != len(str2):
          return False
      
      str1_counts = collections.Counter(str1)
      str2_counts = collections.Counter(str2)
      
      for char in str1_counts:
          if str1_counts[char] != str2_counts[char]:
              return False
              
      return True