Converted invert_dict() to classmethod