I think you can condense these 5 lines into something like this:

``image_tags.set_default(value, []).append(key)``