code: 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:
  
          - 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.
      """
      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
  
imports: from typing import List, Union
  import inspect
  import funcsigs
  from pydoc import locate
  import copy
  import collections
  import numpy
  import tensorflow
  from texar.tf.hyperparams import HParams
  from texar.tf.utils.dtypes import is_str, is_callable, compat_as_text, _maybe_list_to_array
label_desc: Use image node_id 25 for calling a global function with example usage: strip_special_tokens(str_, strip_pad, strip_bos, strip_eos, is_token_list, compat) and returns: s