def __init__(self, sub_attrs, key_value=None, attrs=None, **kwargs):
        widgets = [self.key_type()] if callable(self.key_type) else []
        if self.value_type in [TextInput, HiddenInput]:
            if sub_attrs:
                try:
                    widgets = [self.key_type(attrs=sub_attrs['key']), self.value_type(attrs=sub_attrs['value'])]
                except KeyError:
                    raise KeyError("improper synthax for sub_attrs parameter")
            else:
                widgets = [self.key_type(), self.value_type()]
        elif self.value_type == Dictionary:
            if sub_attrs:
                try:
                    widgets = [self.key_type(attrs=sub_attrs['key']), self.value_type(attrs=sub_attrs['value'], **kwargs)]
                except __HOLE__:
                    raise KeyError("improper synthax for sub_attrs parameter")
            else:
                widgets = [self.key_type(), self.value_type(**kwargs)]
        self.sub_attrs = sub_attrs
        #raise error here ?
        self.key_value = key_value if key_value is not None else ''
        super(Pair, self).__init__(widgets, attrs)

    #this method should be overwritten by subclasses
dataset/ETHPy150Open MongoEngine/django-mongoengine/django_mongoengine/forms/widgets.py/Pair.__init__