def capitalize_acronyms(lex, tokens, as_string=False):
    """Capitalizes all acronyms in ``tokens``.

    Args:
        lex (dict): Lexicon dictionary containing the list of acronyms.
        tokens (list (str)): Tokenized text to be capitalized.
        as_string (boolean): Whether to return the tokens as a list (False) or a string (True).

    Returns:
        list (str): List of tokens if ``as_string`` = False.
        str: Tokenized text if ``as_string`` = True.
    """
    for i in range(len(tokens)):
        if tokens[i] in lex:
            tokens[i] = tokens[i].upper()

    return tokens if not as_string else " ".join(tokens)