def gen_names(v: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])], curnames: List[Name]) -> List[Label]:
    newnames: List[Name]
    if is_scalar(v):
        newnames = [cast(Name, v)]
    elif (is_list_like(v) and (not is_dict_like(v))):
        newnames = list(cast(Sequence[Name], v))
    elif is_dict_like(v):
        v_dict = cast(Dict[(Name, Name)], v)
        newnames = [(v_dict[name] if (name in v_dict) else name) for name in curnames]
    elif callable(v):
        v_callable = cast(Callable[([Name], Name)], v)
        newnames = [v_callable(name) for name in curnames]
    else:
        raise ValueError('`mapper` or `index` or `columns` should be either dict-like or function type.')
    if (len(newnames) != len(curnames)):
        raise ValueError('Length of new names must be {}, got {}'.format(len(curnames), len(newnames)))
    return [(name if is_name_like_tuple(name) else (name,)) for name in newnames]
def gen_names(v: Union[(Any, Sequence[Any], Dict[(Name, Any)], Callable[([Name], Any)])], curnames: List[Name]) -> List[Label]:
    newnames: List[Name]
    if is_scalar(v):
        newnames = [cast(Name, v)]
    elif (is_list_like(v) and (not is_dict_like(v))):
        newnames = list(cast(Sequence[Name], v))
    elif is_dict_like(v):
        v_dict = cast(Dict[(Name, Name)], v)
        newnames = [(v_dict[name] if (name in v_dict) else name) for name in curnames]
    elif callable(v):
        v_callable = cast(Callable[([Name], Name)], v)
        newnames = [v_callable(name) for name in curnames]
    else:
        raise ValueError('`mapper` or `index` or `columns` should be either dict-like or function type.')
    if (len(newnames) != len(curnames)):
        raise ValueError('Length of new names must be {}, got {}'.format(len(curnames), len(newnames)))
    return [(name if is_name_like_tuple(name) else (name,)) for name in newnames]