
    Th
              	           S SK JrJrJr  S SKJr  S SKJrJr  S SK	J
r
  S SKJr  S SKJr  S SKJrJrJrJr  S/r\
" S	5       " S
 S\\\\4      5      5       rg)    )IterableIteratorSized)BufferedIOBase)AnyCallable)functional_datapipe)IterDataPipe)_deprecation_warning)basichandlersDecoderextension_extract_fnimagehandlerRoutedDecoderIterDataPiperouted_decodec            	          ^  \ rS rSrSr\S.S\\\\	4      S\
S\
SS4U 4S	 jjjrS
\
SS4S jrS\\\\4      4S jrS\4S jrSrU =r$ )r      af  
Decodes binary streams from input DataPipe, yields pathname and decoded data in a tuple.

(functional name: ``routed_decode``)

Args:
    datapipe: Iterable datapipe that provides pathname and binary stream in tuples
    handlers: Optional user defined decoder handlers. If ``None``, basic and image decoder
        handlers will be set as default. If multiple handles are provided, the priority
        order follows the order of handlers (the first handler has the top priority)
    key_fn: Function for decoder to extract key from pathname to dispatch handlers.
        Default is set to extract file extension from pathname

Note:
    When ``key_fn`` is specified returning anything other than extension, the default
    handler will not work and users need to specify custom handler. Custom handler
    could use regex to determine the eligibility to handle data.
)key_fndatapipehandlersr   returnNc                   > [         TU ]  5         Xl        U(       d  [        [	        S5      4n[        USU06U l        [        [        U 5      R                  SSSS9  g )Ntorchr   z1.12z1.13r   )deprecation_versionremoval_versionold_functional_name)
super__init__r   decoder_basichandlersdecoder_imagehandlerr   decoderr   type__name__)selfr   r   r   	__class__s       g/var/www/fran/franai/venv/lib/python3.13/site-packages/torch/utils/data/datapipes/iter/routeddecoder.pyr   "RoutedDecoderIterDataPipe.__init__(   sW     	>F-/CG/LMH88J &" /		
    handlerc                 6    U R                   R                  " U6   g )N)r!   add_handler)r$   r)   s     r&   r+   %RoutedDecoderIterDataPipe.add_handler:   s      '*r(   c              #   n   #    U R                    H!  nUS   nU R                  U5      nX#U   4v   M#     g 7f)Nr   r   r!   )r$   datapathnameresults       r&   __iter__"RoutedDecoderIterDataPipe.__iter__=   s8     MMDAwH\\$'FH-.. "s   35c                     [        U R                  [        5      (       a  [        U R                  5      $ [	        [        U 5      R                   S35      e)Nz# instance doesn't have valid length)
isinstancer   r   len	TypeErrorr"   r#   )r$   s    r&   __len__!RoutedDecoderIterDataPipe.__len__C   s@    dmmU++t}}%%4:..//RSTTr(   r.   )r#   
__module____qualname____firstlineno____doc__r   r   tuplestrr   r   r   r+   r   r   r2   intr8   __static_attributes____classcell__)r%   s   @r&   r   r      s    . 0	
5n!456
 
 	

 

 
$+H + +/(5c?3 /U U Ur(   N)collections.abcr   r   r   ior   typingr   r   %torch.utils.data.datapipes._decoratorr	   #torch.utils.data.datapipes.datapiper
   'torch.utils.data.datapipes.utils.commonr   (torch.utils.data.datapipes.utils.decoderr   r   r   r   r   r    __all__r>   r?   r    r(   r&   <module>rL      s^    5 5    E < H  '
' _%2UU38_ = 2U &2Ur(   