code: def _fetch_message(self, buffer, has_new_line=False):
      messages = []
      while (len(buffer)) >= 16:
          header = buffer[:16]
          length = int(header[2:])
  
          message_length = length + 16
          total_length = message_length
          if has_new_line:
              total_length += 1
  
          # break, if buffer is too short.
          if len(buffer) < total_length:
              break
          data = buffer[16:message_length]
          if has_new_line and 10 != buffer[total_length - 1]:
              nni_log(
                  LogType.Error,
                  "end of message should be \\n, but got {}".format(
                      self.in_cache[total_length - 1]
                  ),
              )
          buffer = buffer[total_length:]
          messages.append(header + data)
  
      return messages, buffer
  
imports: import json
  import threading
  import time
  from abc import ABC, abstractmethod
  from queue import Empty, Queue
  from .log_utils import LogType, nni_log
  from .commands import CommandType
label_desc: Use image node_id 12 for calling the BaseChannel obj's underlying member method code with example usage: obj._fetch_message(buffer, has_new_line) and returns: messages,  buffer