class_docstr: SharedBatchesDispatcher serializes batches, puts them into provided
  shared memory chunks along with completed task description and puts information
  about ready chunks into the `queue`. It processes tasks in a separate thread to
  overlap serialization of minibatches with next minibatches computation in case of
  a callback waiting on IO extensively and to avoid multiple worker processes
  waiting on inter-process ShmQueue access
class_docstr_tok: ["SharedBatchesDispatcher","serializes","batches",",","puts","them","into","provided","shared","memory","chunks","along","with","completed","task","description","and","puts","information","about","ready","chunks","into","the","`","queue","`",".","It","processes","tasks","in","a","separate","thread","to","overlap","serialization","of","minibatches","with","next","minibatches","computation","in","case","of","a","callback","waiting","on","IO","extensively","and","to","avoid","multiple","worker","processes","waiting","on","inter-process","ShmQueue","access"]
code: def serialize_msgs(
      self, processed_tasks: List[_WorkerProcessingResult]
  ):
      shm_msgs = []
      for processed_task in processed_tasks:
          if processed_task.is_failed():  # one of the tasks failed
              shm_msgs.append(
                  self._serialize_failed_task(processed_task)
              )
          else:
              shm_msgs.append(self._serialize_done_task(processed_task))
      return shm_msgs
  
imports: from typing import List, Optional, Tuple
  import threading
  import traceback
  import socket
  from collections import deque
  from multiprocessing import reduction
  from nvidia.dali._utils.external_source_impl import SourceKind, _is_generator_function
  from nvidia.dali._multiproc.shared_batch import SharedBatchWriter, SharedBatchMeta, BufShmChunk, assert_valid_data_type, read_shm_message, write_shm_message
  from nvidia.dali._multiproc.messages import CompletedTask, WorkerArgs, ShmMessageDesc, ScheduledTask
  from nvidia.dali._multiproc.shared_queue import Dispatcher
label_desc: Use image node_id 4 for calling the SharedBatchDispatcher obj's underlying member method code with example usage: obj.serialize_msgs(processed_tasks) and returns: shm_msgs