input: Write a function to invert a dictionary where each key-value pair is transformed such that keys become values and values become keys. If a value appears multiple times in the original dictionary, the inverted dictionary should group all corresponding keys into a list. If the input dictionary is empty, the function should return an empty dictionary.
  
  assert invert_dictionary({}) == {}
  assert invert_dictionary({"a": 1, "b": 2, "c": 3}) == {1: ["a"], 2: ["b"], 3: ["c"]}
  assert invert_dictionary({"a": "apple", "b": "banana", "c": "apple"}) == {"apple": ["a", "c"], "banana": ["b"]}
  assert invert_dictionary({"one": 1, "two": 2, "three": 1}) == {1: ["one", "three"], 2: ["two"]}
output: def invert_dictionary(d):
      inverted = {}
      for key, value in d.items():
          if value in inverted:
              inverted[value].append(key)
          else:
              inverted[value] = [key]
      return inverted