from typing import Union


def _calc_n_kwargs(args: list[str]) -> Union[str, int]:
    """
    Here we try to calculate the nargs for **kwargs arguments.
    Basically we are starting from the end until not encountering
    the "=" sign in the provided argument.
    Example: <CLI> <feature> <command> [arguments: pos[bst labs] *args[lib1 lib2] **kwargs[name1=lib1 name2=lib2]]
    :param args: the list of arguments from the argparse
    :return: nargs for argparse add_argument()
    """
    n_kwargs = 0
    for n_kwargs in range(0, -len(args), -1):
        if "=" not in args[n_kwargs - 1]:
            break
    return -n_kwargs or "*"