def widget_generator(klass, fields):
    """
    Takes in a class and a list of tuples consisting of field_name and an attribute dictionary
    :param klass: Class of the input widget
    :param fields: List of tuples mapping field names to attribute dictionaries
    :return: A dict of input widget instances
    """

    widgets = {}

    for field_name, attrs in fields:
        widgets[field_name] = klass(attrs=attrs)

    return widgets