code: def trim_string(s, max_bytes):
      """
      Adjusts the length of the string s in order to fit it
      into max_bytes bytes of storage after encoding as UTF-8.
      Useful when cutting filesystem paths.
      :param s: unicode string
      :param max_bytes: number of bytes
      :return the prefix of s
      """
      if isinstance(s, six.text_type):
          return _trim_unicode_string(s, max_bytes)
  
      if isinstance(s, six.binary_type):
          if len(s) <= max_bytes:
              return s
          s = s.decode("utf-8", errors="ignore")
          s = _trim_unicode_string(s, max_bytes)
          s = s.encode("utf-8", errors="ignore")
          return s
  
      raise TypeError("a string is expected")
  
imports: import six
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: trim_string(s, max_bytes) and returns: _trim_unicode_string, s, s