Return a FormGroup class for the given form[set] form_classes.

def formgroup_factory(form_classes,
                      formgroup=None,
                      state_validators=None,
                      ):
    """Return a FormGroup class for the given form[set] form_classes.

    """

    base_class = formgroup or FormGroup
    if state_validators is not None:
        base_class = StateValidatorFormGroup

    if not issubclass(base_class, FormGroup):
        raise TypeError("Base formgroup class must subclass FormGroup.")

    return type(
        'FormGroup',
        (base_class,),
        dict(
            form_classes=form_classes,
            state_validators=state_validators,
        ),
    )