Invert an object, such that keys become values and values become keys, according to a transform function.