def _dump(config_instance, dict_type=OrderedDict):
if not is_config(config_instance):<EOL><INDENT>raise ValueError(<EOL>f"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>result = dict_type()<EOL>for var in attr.fields(config_instance.__class__):<EOL><INDENT>if not is_config_var(var):<EOL><INDENT>continue<EOL><DEDENT>entry = var.metadata[CONFIG_KEY]<EOL>dump_key = entry.name if entry.name else var.name<EOL>dump_default = var.default if var.default else None<EOL>if callable(entry.encoder):<EOL><INDENT>result[dump_key] = entry.encoder(<EOL>getattr(config_instance, var.name, dump_default)<EOL>)<EOL>continue<EOL><DEDENT>if is_array_type(entry.type):<EOL><INDENT>items = getattr(config_instance, var.name, [])<EOL>if items is not None:<EOL><INDENT>result[dump_key] = [<EOL>(_dump(item, dict_type=dict_type) if is_config(item) else item)<EOL>for item in items<EOL>]<EOL><DEDENT><DEDENT>elif is_enum_type(entry.type):<EOL><INDENT>dump_value = getattr(config_instance, var.name, dump_default)<EOL>result[dump_key] = (<EOL>dump_value.value if dump_value in entry.type else dump_value<EOL>)<EOL><DEDENT>elif is_bytes_type(entry.type):<EOL><INDENT>result[dump_key] = encode_bytes(<EOL>getattr(config_instance, var.name, dump_default)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>if is_config_type(entry.type):<EOL><INDENT>result[dump_key] = _dump(<EOL>getattr(config_instance, var.name, {}), dict_type=dict_type<EOL>)<EOL><DEDENT>else:<EOL><INDENT>dump_value = getattr(config_instance, var.name, dump_default)<EOL>if is_object_type(type(dump_value)):<EOL><INDENT>dump_value = {<EOL>key: (<EOL>_dump(value, dict_type=dict_type)<EOL>if is_config(value)<EOL>else value<EOL>)<EOL>for (key, value) in dump_value.items()<EOL>}<EOL><DEDENT>if dump_value is not None:<EOL><INDENT>result[dump_key] = dump_value<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>
Dumps an instance from ``instance`` to a dictionary type mapping.

    :param object instance: The instance to serialized to a dictionary
    :param object dict_type: Some dictionary type, defaults to ``OrderedDict``
    :return: Dumped dictionary
    :rtype: collections.OrderedDict (or instance of ``dict_type``)