code: def to_str(value, to_enc=DEFAULT_ENCODING, from_enc=None):
      if isinstance(value, six.binary_type):
          if from_enc is None or to_enc == from_enc:
              # Unknown input encoding or input and output encoding are the same
              return value
          value = to_unicode(value, from_enc=from_enc)
      if isinstance(value, six.text_type):
          return value.encode(to_enc, ENCODING_ERRORS_POLICY)
      return six.binary_type(value)
  
imports: import locale
  import logging
  import six
  import sys
  import codecs
  import library.python.func
label_desc: Use image node_id 4 for calling a global function with example usage: to_str(value, to_enc, from_enc) and returns: six, value, value