code: def strip_bos(
      str_, bos_token="<BOS>", is_token_list=False, compat=True
  ):
      """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 _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
  
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 24 for calling a global function with example usage: strip_bos(str_, bos_token, is_token_list, compat) and returns: strp_str, _maybe_list_to_array, str, str