code: def _trim_unicode_string(s, max_bytes):
      if len(s) * 4 <= max_bytes:
          # UTF-8 uses at most 4 bytes per character
          return s
  
      result = []
      cur_byte_length = 0
  
      for ch in s:
          cur_byte_length += len(ch.encode("utf-8"))
          if cur_byte_length > max_bytes:
              break
          result.append(ch)
  
      return "".join(result)
  
imports: import six
  import sys
label_desc: Use image node_id 3 for calling a global function with example usage: _trim_unicode_string(s, max_bytes) and returns: str, s