def create_config_class(
    class_name: str,
    default_config: dict[str, ConfigParam],
    base: type = ConfigBase,
    validators: dict[str, Callable] = None,
) -> type[ConfigBase]:
    """Create a Pydantic model class from a configuration dictionary."""
    config = {}
    validators = validators.copy() if validators else {}
    for param, param_config in default_config.items():
        # automatically add validator for object params
        if param_config.category == ParamCategory.OBJECT:
            validator_name = f"validate_{param}_object"
            count = 0
            while validator_name in validators:
                validator_name = f"{validator_name}_{count}"
                count += 1
            validators[validator_name] = validator(param, allow_reuse=True)(validate_object)

        type_ = param_config.type_
        if param_config.required:
            config[param] = (type_, ...)
            continue

        config[param] = (Optional[type_], param_config.default_value)

    return create_model(class_name, **config, __base__=base, __validators__=validators)
Create a Pydantic model class from a configuration dictionary.
olive/common/config_utils.py