code: def pull_logs(generator, stop, until, final_pull):
      """Placeholder docstring"""
      now = datetime.now()
      if until < now:
          return
  
      logs = queue.Queue(maxsize=10)
      log_puller = Thread(
          target=_get_logs,
          args=(
              generator,
              logs,
              until,
          ),
      )
      log_puller.start()
  
      while True:
          try:
              top = logs.get(
                  block=True, timeout=(until - now).total_seconds()
              )
              logger.debug(top)
  
              if "[INFO ]" in top and "OutOfMemoryError" in top:
                  raise LocalModelOutOfMemoryException(top)
              if "CUDA out of memory. Tried to allocate" in top:
                  raise LocalModelOutOfMemoryException(top)
              if "ai.djl.engine.EngineException: OOM" in top:
                  raise LocalModelOutOfMemoryException(top)
              if "4xx.Count:1" in top or "5xx.Count:1" in top:
                  raise LocalModelInvocationException(top)
              if "[ERROR]" in top or "Failed register workflow" in top:
                  raise LocalModelLoadException(top)
              if "Address already in use" in top:
                  raise LocalModelLoadException(top)
              if "not compatible with sharding" in top:
                  raise SkipTuningComboException(top)
          except (
              LocalModelLoadException,
              LocalModelOutOfMemoryException,
              LocalModelInvocationException,
          ) as e:
              stop()
              log_puller.join(timeout=5)
              raise e
          except queue.Empty:
              now = datetime.now()
              if until < now:
                  if not final_pull:
                      return
  
                  stop()
                  # allow logging thread some time to cleanup
                  log_puller.join(timeout=5)
                  if log_puller.is_alive():
                      raise Exception("Logging thread not terminating")
                  return
  
imports: from __future__ import absolute_import
  import logging
  from threading import Thread
  import queue
  from datetime import datetime
  from sagemaker.serve.utils.exceptions import LocalModelLoadException, LocalModelOutOfMemoryException, LocalModelInvocationException, SkipTuningComboException
label_desc: Use image node_id 2 for calling a global function with example usage: pull_logs(generator, stop, until, final_pull) without return types