
    Pi{                         d dl mZ d dlZd dlZd dlmZmZ d dlZd dl	m
Z d dlmZ ddlmZ dedeej        ej        f         deej        ej        f         d	ed
eej        ej        f         f
dZdS )    N)CallableUnion)ExceptionWrapper   )QUEUE_TIMEOUT	worker_idin_qout_qudf
stop_eventc                 8   t          j        d           	 |                                r|                                rdS 	 |                    dt
                    \  }}n# t          j        $ r Y ]w xY wt          |t                    r|
                    ||fd           nut          |t                    r|
                    ||fd           nF	  ||          }n # t          $ r t          d          }Y nw xY w|
                    ||fd           )	aX  _apply_udf assumes in_q emits tuples of (x, idx) where x is the
    payload, idx is the index of the result, potentially used for maintaining
    ordered outputs. For every input it pulls, a tuple (y, idx) is put on the out_q
    where the output of udf(x), an ExceptionWrapper, or StopIteration (if it pulled
    StopIteration from in_q).
    r   T)blocktimeoutF)r   zin _apply_udf)whereN)torchset_num_threadsis_setemptygetr   queueEmpty
isinstancer   putStopIteration	Exception)r   r	   r
   r   r   itemidxys           n/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/torchdata/nodes/_apply_udf.py
_apply_udfr       sI    
!- 	4::<< 	E	t]CCID##{ 	 	 	H	 d,-- 
	-IItSkI////m,, 	-IItSkI////<CII < < <$?;;;< IIq#heI,,,'-s$   A! !A32A3C! !C>=C>)multiprocessing.synchronizesynchronizepython_mp_synchronizer   	threadingtypingr   r   r   torch.multiprocessingmultiprocessingmptorch._utilsr   	constantsr   intQueueEventr         r   <module>r0      s    < ; ; ; ; ;      " " " " " " " "  " " " " " " ) ) ) ) ) ) $ $ $ $ $ $!-!-
RX%
&!- bh&'!- 
	!-
 io'<'BBC!- !- !- !- !- !-r/   