code: def compat_as_text(str_):
      """Converts strings into `unicode` (Python 2) or `str` (Python 3).
  
      Args:
          str_: A string or other data types convertible to string, or an
              `n`-D numpy array or (possibly nested) list of such elements.
  
      Returns:
          The converted strings of the same structure/shape as :attr:`str_`.
      """
  
      def _recur_convert(s):
          if isinstance(s, (list, tuple, np.ndarray)):
              s_ = [_recur_convert(si) for si in s]
              return _maybe_list_to_array(s_, s)
          else:
              try:
                  return tf.compat.as_text(s)
              except TypeError:
                  return tf.compat.as_text(str(s))
  
      text = _recur_convert(str_)
  
      return text
  
file_path: texar/texar/tf/utils/dtypes.py
imports: import six
  import numpy
  import tensorflow
label_desc: Use image node_id 7 for calling a global function with example usage: compat_as_text(str_) and returns: text, _maybe_list_to_array, tf, tf