def strip_bos(str_, bos_token='<BOS>', is_token_list=False, compat=True):
    "Remove all leading BOS tokens.\n\n    Note that besides :attr:`bos_token`, all leading and trailing whitespace\n    characters are also removed.\n\n    If :attr:`is_token_list` is False, then the function assumes tokens in\n    :attr:`str_` are separated with whitespace character.\n\n    Args:\n        str_: A `str`, or an `n`-D numpy array or (possibly nested)\n            list of `str`.\n        bos_token (str): The BOS token. Default is '<BOS>' as defined in\n            :class:`~texar.tf.data.SpecialTokens`.BOS\n        is_token_list (bool): Whether each sentence in :attr:`str_` is a list\n            of tokens. If False, each sentence in :attr:`str_` is assumed to\n            contain tokens separated with space character.\n        compat (bool): Whether to convert tokens into `unicode` (Python 2)\n            or `str` (Python 3).\n\n    Returns:\n        Strings of the same structure/shape as :attr:`str_`.\n    "

    def _recur_strip(s):
        if is_str(s):
            if (bos_token == ''):
                return ' '.join(s.strip().split())
            else:
                return ' '.join(s.strip().split()).replace((bos_token + ' '), '')
        else:
            s_ = [_recur_strip(si) for si in s]
            return _maybe_list_to_array(s_, s)
    s = str_
    if compat:
        s = compat_as_text(s)
    if is_token_list:
        s = str_join(s, compat=False)
    strp_str = _recur_strip(s)
    if is_token_list:
        strp_str = _recur_split(strp_str, str_)
    return strp_str
Remove all leading BOS tokens.

Note that besides :attr:`bos_token`, all leading and trailing whitespace
characters are also removed.

If :attr:`is_token_list` is False, then the function assumes tokens in
:attr:`str_` are separated with whitespace character.

Args:
    str_: A `str`, or an `n`-D numpy array or (possibly nested)
        list of `str`.
    bos_token (str): The BOS token. Default is '<BOS>' as defined in
        :class:`~texar.tf.data.SpecialTokens`.BOS
    is_token_list (bool): Whether each sentence in :attr:`str_` is a list
        of tokens. If False, each sentence in :attr:`str_` is assumed to
        contain tokens separated with space character.
    compat (bool): Whether to convert tokens into `unicode` (Python 2)
        or `str` (Python 3).

Returns:
    Strings of the same structure/shape as :attr:`str_`.
def strip_bos(str_, bos_token='<BOS>', is_token_list=False, compat=True):
    "Remove all leading BOS tokens.\n\n    Note that besides :attr:`bos_token`, all leading and trailing whitespace\n    characters are also removed.\n\n    If :attr:`is_token_list` is False, then the function assumes tokens in\n    :attr:`str_` are separated with whitespace character.\n\n    Args:\n        str_: A `str`, or an `n`-D numpy array or (possibly nested)\n            list of `str`.\n        bos_token (str): The BOS token. Default is '<BOS>' as defined in\n            :class:`~texar.tf.data.SpecialTokens`.BOS\n        is_token_list (bool): Whether each sentence in :attr:`str_` is a list\n            of tokens. If False, each sentence in :attr:`str_` is assumed to\n            contain tokens separated with space character.\n        compat (bool): Whether to convert tokens into `unicode` (Python 2)\n            or `str` (Python 3).\n\n    Returns:\n        Strings of the same structure/shape as :attr:`str_`.\n    "

    def _recur_strip(s):
        if is_str(s):
            if (bos_token == ):
                return ' '.join(s.strip().split())
            else:
                return ' '.join(s.strip().split()).replace((bos_token + ' '), )
        else:
            s_ = [_recur_strip(si) for si in s]
            return _maybe_list_to_array(s_, s)
    s = str_
    if compat:
        s = compat_as_text(s)
    if is_token_list:
        s = str_join(s, compat=False)
    strp_str = _recur_strip(s)
    if is_token_list:
        strp_str = _recur_split(strp_str, str_)
    return strp_str