  import queue as Queue
  import sys
  import threading
  from lib.logger import LOG_QUEUE, set_root_logger
  
  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  _launched_processes = set()  # pylint: disable=invalid-name
 
</s> remove from lib.multithreading import MultiThread
 </s> add from lib.multithreading import MultiThread, FixedProducerDispatcher </s> remove         q_size = batchsize * 8
        # Don't use a multiprocessing queue because sometimes the MP Manager borks on numpy arrays
        queue_manager.add_queue(q_name, maxsize=q_size, multiprocessing_queue=False)
        load_thread = MultiThread(self.load_batches,
                                  images,
                                  q_name,
                                  side,
                                  is_timelapse,
                                  do_shuffle)
 </s> add         load_thread = FixedProducerDispatcher(
            self.load_batches,
            batch_shape,
            args=(images, q_name, side, is_timelapse, do_shuffle, batchsize),
            log_queue=queue_manager._log_queue,
            log_level=logger.getEffectiveLevel(),
        ) </s> remove         queue = queue_manager.get_queue(q_name)
        while True:
            if load_thread.has_error:
                logger.debug("Thread error detected")
                break
            batch = list()
            for _ in range(self.batchsize):
                images = queue.get()
                for idx, image in enumerate(images):
                    if len(batch) < idx + 1:
                        batch.append(list())
                    batch[idx].append(image)
            batch = [np.float32(image) for image in batch]
            logger.trace("Yielding batch: (size: %s, item shapes: %s, queue:  '%s'",
                         len(batch), [item.shape for item in batch], q_name)
            yield batch
 </s> add         for batch_wrapper in load_thread:
            with batch_wrapper as batch:
                logger.trace("Yielding batch: (size: %s, item shapes: %s, queue:  '%s'",
                             len(batch), [item.shape for item in batch], q_name)
                yield batch
        load_thread.stop()
import numpy as np
from ctypes import c_float
  import queue as Queue
  import sys
  import threading
import numpy as np
from ctypes import c_float
  from lib.logger import LOG_QUEUE, set_root_logger
  
  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  _launched_processes = set()  # pylint: disable=invalid-name
keep keep add keep keep keep keep
 Added multithreading dispatcher for training_data 
lib/multithreading.py