def strip_special_tokens(str_, strip_pad='<PAD>', strip_bos='<BOS>', strip_eos='<EOS>', is_token_list=False, compat=True):
    "Removes special tokens in strings, including:\n\n        - Removes EOS and all subsequent tokens\n        - Removes leading and and trailing PAD tokens\n        - Removes leading BOS tokens\n\n    Note that besides the special tokens, all leading and trailing whitespace\n    characters are also removed.\n\n    This is a joint function of :func:`strip_eos`, :func:`strip_pad`, and\n    :func:`strip_bos`\n\n    Args:\n        str_: A `str`, or an `n`-D numpy array or (possibly nested)\n            list of `str`.\n        strip_pad (str): The PAD token to strip from the strings (i.e., remove\n            the leading and trailing PAD tokens of the strings). Default\n            is '<PAD>' as defined in\n            :class:`~texar.tf.data.SpecialTokens`.PAD.\n            Set to `None` or `False` to disable the stripping.\n        strip_bos (str): The BOS token to strip from the strings (i.e., remove\n            the leading BOS tokens of the strings).\n            Default is '<BOS>' as defined in\n            :class:`~texar.tf.data.SpecialTokens`.BOS.\n            Set to `None` or `False` to disable the stripping.\n        strip_eos (str): The EOS token to strip from the strings (i.e., remove\n            the EOS tokens and all subsequent tokens of the strings).\n            Default is '<EOS>' as defined in\n            :class:`~texar.tf.data.SpecialTokens`.EOS.\n            Set to `None` or `False` to disable the stripping.\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 shape of :attr:`str_` with special tokens stripped.\n    "
    s = str_
    if compat:
        s = compat_as_text(s)
    if is_token_list:
        s = str_join(s, compat=False)
    if ((strip_eos is not None) and (strip_eos is not False)):
        s = _strip_eos_(s, strip_eos, is_token_list=False, compat=False)
    if ((strip_pad is not None) and (strip_pad is not False)):
        s = strip_token(s, strip_pad, is_token_list=False, compat=False)
    if ((strip_bos is not None) and (strip_bos is not False)):
        s = _strip_bos_(s, strip_bos, is_token_list=False, compat=False)
    if is_token_list:
        s = _recur_split(s, str_)
    return s
Removes special tokens in strings, including:

    - Removes EOS and all subsequent tokens
    - Removes leading and and trailing PAD tokens
    - Removes leading BOS tokens

Note that besides the special tokens, all leading and trailing whitespace
characters are also removed.

This is a joint function of :func:`strip_eos`, :func:`strip_pad`, and
:func:`strip_bos`

Args:
    str_: A `str`, or an `n`-D numpy array or (possibly nested)
        list of `str`.
    strip_pad (str): The PAD token to strip from the strings (i.e., remove
        the leading and trailing PAD tokens of the strings). Default
        is '<PAD>' as defined in
        :class:`~texar.tf.data.SpecialTokens`.PAD.
        Set to `None` or `False` to disable the stripping.
    strip_bos (str): The BOS token to strip from the strings (i.e., remove
        the leading BOS tokens of the strings).
        Default is '<BOS>' as defined in
        :class:`~texar.tf.data.SpecialTokens`.BOS.
        Set to `None` or `False` to disable the stripping.
    strip_eos (str): The EOS token to strip from the strings (i.e., remove
        the EOS tokens and all subsequent tokens of the strings).
        Default is '<EOS>' as defined in
        :class:`~texar.tf.data.SpecialTokens`.EOS.
        Set to `None` or `False` to disable the stripping.
    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 shape of :attr:`str_` with special tokens stripped.
def strip_special_tokens(str_, strip_pad='<PAD>', strip_bos='<BOS>', strip_eos='<EOS>', is_token_list=False, compat=True):
    "Removes special tokens in strings, including:\n\n        - Removes EOS and all subsequent tokens\n        - Removes leading and and trailing PAD tokens\n        - Removes leading BOS tokens\n\n    Note that besides the special tokens, all leading and trailing whitespace\n    characters are also removed.\n\n    This is a joint function of :func:`strip_eos`, :func:`strip_pad`, and\n    :func:`strip_bos`\n\n    Args:\n        str_: A `str`, or an `n`-D numpy array or (possibly nested)\n            list of `str`.\n        strip_pad (str): The PAD token to strip from the strings (i.e., remove\n            the leading and trailing PAD tokens of the strings). Default\n            is '<PAD>' as defined in\n            :class:`~texar.tf.data.SpecialTokens`.PAD.\n            Set to `None` or `False` to disable the stripping.\n        strip_bos (str): The BOS token to strip from the strings (i.e., remove\n            the leading BOS tokens of the strings).\n            Default is '<BOS>' as defined in\n            :class:`~texar.tf.data.SpecialTokens`.BOS.\n            Set to `None` or `False` to disable the stripping.\n        strip_eos (str): The EOS token to strip from the strings (i.e., remove\n            the EOS tokens and all subsequent tokens of the strings).\n            Default is '<EOS>' as defined in\n            :class:`~texar.tf.data.SpecialTokens`.EOS.\n            Set to `None` or `False` to disable the stripping.\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 shape of :attr:`str_` with special tokens stripped.\n    "
    s = str_
    if compat:
        s = compat_as_text(s)
    if is_token_list:
        s = str_join(s, compat=False)
    if ((strip_eos is not None) and (strip_eos is not False)):
        s = _strip_eos_(s, strip_eos, is_token_list=False, compat=False)
    if ((strip_pad is not None) and (strip_pad is not False)):
        s = strip_token(s, strip_pad, is_token_list=False, compat=False)
    if ((strip_bos is not None) and (strip_bos is not False)):
        s = _strip_bos_(s, strip_bos, is_token_list=False, compat=False)
    if is_token_list:
        s = _recur_split(s, str_)
    return s