code: def to_basestring(value):
      if isinstance(value, (six.binary_type, six.text_type)):
          return value
      try:
          if six.PY2:
              return unicode(value)  # noqa
          else:
              return str(value)
      except UnicodeDecodeError:
          try:
              return str(value)
          except UnicodeEncodeError:
              return repr(value)
  
imports: import locale
  import logging
  import six
  import sys
  import codecs
  import library.python.func
label_desc: Use image node_id 2 for calling a global function with example usage: to_basestring(value) and returns: value, unicode, str, str, repr