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 CompletedTask instance (that describes an error encountered when producing batch)
  in the provided shared memory chunk (`processed_task.shm_chunk`).
  Returns `ShmMessageDesc` instance, that describes shared memory chunk and placement
   offset=0, size) of the serialized CompletedTask instance in the chunk.
docstr_tok: ["Puts","CompletedTask","instance","(","that","describes","an","error","encountered","when","producing","batch",")","in","the","provided","shared","memory","chunk","(","`","processed_task.shm_chunk","`",")",".","Returns","`","ShmMessageDesc","`","instance",",","that","describes","shared","memory","chunk","and","placement","offset=0",",","size",")","of","the","serialized","CompletedTask","instance","in","the","chunk","."]
code: def _serialize_failed_task(
      self, processed_task: _WorkerProcessingResult
  ):
      """
      Puts CompletedTask instance (that describes an error encountered when producing batch)
      in the provided shared memory chunk (`processed_task.shm_chunk`).
      Returns `ShmMessageDesc` instance, that describes shared memory chunk and placement
       offset=0, size) of the serialized CompletedTask instance in the chunk.
      """
      shm_chunk = processed_task.shm_chunk
      completed_task = CompletedTask.failed(
          self.worker_id, processed_task
      )
      return write_shm_message(
          self.worker_id, shm_chunk, completed_task, 0, 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 2 for calling the SharedBatchDispatcher obj's underlying member method code with example usage: obj._serialize_failed_task(processed_task) and returns: write_shm_message