def flag_to_list(flagval, flagtype):
    """Convert a string of comma-separated tf flags to a list of values."""
    if flagtype == 'int':
        return [int(_) for _ in flagval.split(',') if _]

    elif flagtype == 'float':
        return [float(_) for _ in flagval.split(',') if _]

    elif flagtype == 'str':
        return [_ for _ in flagval.split(',') if _]

    else:
        raise Exception("incorrect type")
Convert a string of comma-separated tf flags to a list of values.