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"]
docstr: Puts produced batch in the provided shared memory chunk (`processed_task.shm_chunk`).
  Layout of the data in the chunk:
  [1. samples from the batch | 2. batch meta-data | 3. completed task].
  1. Binary encoded samples from the batch (underlying data of numpy arrays),
     aimed to be used as initialization buffers for arrays with no additional copy
     or deserialization.
  2. Pickled list of meta-data of each sample, such as the sample's binary data offset in
     the chunk, a shape and a type of the array.
  3. Pickled CompletedTask instance (that contains offset and size of the serialized list
     from the second point).
  Returns `ShmMessageDesc` instance, that describes shared memory chunk and placement
  (offset, size) of the serialized CompletedTask instance in the chunk.
docstr_tok: ["Puts","produced","batch","in","the","provided","shared","memory","chunk","(","`","processed_task.shm_chunk","`",")",".","Layout","of","the","data","in","the","chunk",":","[","1.","samples","from","the","batch","|","2.","batch","meta-data","|","3.","completed","task","]",".","1",".","Binary","encoded","samples","from","the","batch","(","underlying","data","of","numpy","arrays",")",",","aimed","to","be","used","as","initialization","buffers","for","arrays","with","no","additional","copy","or","deserialization",".","2",".","Pickled","list","of","meta-data","of","each","sample",",","such","as","the","sample","'s","binary","data","offset","in","the","chunk",",","a","shape","and","a","type","of","the","array",".","3",".","Pickled","CompletedTask","instance","(","that","contains","offset","and","size","of","the","serialized","list","from","the","second","point",")",".","Returns","`","ShmMessageDesc","`","instance",",","that","describes","shared","memory","chunk","and","placement","(","offset",",","size",")","of","the","serialized","CompletedTask","instance","in","the","chunk","."]
code: def _serialize_done_task(
      self, processed_task: _WorkerProcessingResult
  ):
      """
      Puts produced batch in the provided shared memory chunk (`processed_task.shm_chunk`).
      Layout of the data in the chunk:
      [1. samples from the batch | 2. batch meta-data | 3. completed task].
      1. Binary encoded samples from the batch (underlying data of numpy arrays),
         aimed to be used as initialization buffers for arrays with no additional copy
         or deserialization.
      2. Pickled list of meta-data of each sample, such as the sample's binary data offset in
         the chunk, a shape and a type of the array.
      3. Pickled CompletedTask instance (that contains offset and size of the serialized list
         from the second point).
      Returns `ShmMessageDesc` instance, that describes shared memory chunk and placement
      (offset, size) of the serialized CompletedTask instance in the chunk.
      """
      shm_chunk = processed_task.shm_chunk
      sbw = SharedBatchWriter(shm_chunk, processed_task.data_batch)
      batch_meta = SharedBatchMeta.from_writer(sbw)
      completed_task = CompletedTask.done(
          self.worker_id, processed_task, batch_meta
      )
      return write_shm_message(
          self.worker_id,
          shm_chunk,
          completed_task,
          sbw.total_size,
          resize=True,
      )
  
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 3 for calling the SharedBatchDispatcher obj's underlying member method code with example usage: obj._serialize_done_task(processed_task) and returns: write_shm_message