def dict2dzn(
    objs, declare=False, assign=True, declare_enums=True, wrap=True, fout=None
):
    """Serializes the objects in input and produces a list of strings encoding
    them into dzn format. Optionally, the produced dzn is written on a file.

    Supported types of objects include: ``str``, ``int``, ``float``, ``set``,
    ``list`` or ``dict``. List and dict are serialized into dzn
    (multi-dimensional) arrays. The key-set of a dict is used as index-set of
    dzn arrays. The index-set of a list is implicitly set to ``1 .. len(list)``.

    Parameters
    ----------
    objs : dict
        A dictionary containing the objects to serialize, the keys are the names
        of the variables.
    declare : bool
        Whether to include the declaration of the variable in the statements or
        just the assignment. Default is ``False``.
    assign : bool
        Whether to include assignment of the value in the statements or just the
        declaration.
    declare_enums : bool
        Whether to declare the enums found as types of the objects to serialize.
        Default is ``True``.
    wrap : bool
        Whether to wrap the serialized values.
    fout : str
        Path to the output file, if None no output file is written.

    Returns
    -------
    list
        List of strings containing the dzn-encoded objects.
    """
    log = logging.getLogger(__name__)

    vals = []
    enums = set()
    for key, val in objs.items():
        if _is_enum(val) and declare_enums:
            enum_type = type(val)
            enum_name = enum_type.__name__
            if enum_name not in enums:
                enum_stmt = stmt2enum(
                    enum_type, declare=declare, assign=assign, wrap=wrap
                )
                vals.append(enum_stmt)
                enums.add(enum_name)
        stmt = stmt2dzn(key, val, declare=declare, assign=assign, wrap=wrap)
        vals.append(stmt)

    if fout:
        log.debug('Writing file: {}'.format(fout))
        with open(fout, 'w') as f:
            for val in vals:
                f.write('{}\n\n'.format(val))
    return vals
Serializes the objects in input and produces a list of strings encoding
    them into dzn format. Optionally, the produced dzn is written on a file.

    Supported types of objects include: ``str``, ``int``, ``float``, ``set``,
    ``list`` or ``dict``. List and dict are serialized into dzn
    (multi-dimensional) arrays. The key-set of a dict is used as index-set of
    dzn arrays. The index-set of a list is implicitly set to ``1 .. len(list)``.

    Parameters
    ----------
    objs : dict
        A dictionary containing the objects to serialize, the keys are the names
        of the variables.
    declare : bool
        Whether to include the declaration of the variable in the statements or
        just the assignment. Default is ``False``.
    assign : bool
        Whether to include assignment of the value in the statements or just the
        declaration.
    declare_enums : bool
        Whether to declare the enums found as types of the objects to serialize.
        Default is ``True``.
    wrap : bool
        Whether to wrap the serialized values.
    fout : str
        Path to the output file, if None no output file is written.

    Returns
    -------
    list
        List of strings containing the dzn-encoded objects.