def complicated_to_yaml(cfg):
    """
    write complex dict structure to yaml
    :param cfg:
    :return:
    """
    from ruamel.yaml import YAML
    yaml = YAML()
    isconverted = {}
    for key, value in cfg.items():
        if type(value) in (str, int, float, bool):
            isconverted[key] = False
            if type(value) is str:
                pass
        else:
            isconverted[key] = True
            cfg[key] = yaml.dump(value, default_flow_style=True)
    return cfg
