§
    ‚Štjn  ã                   óè   — d dl mZmZ d dlmZmZmZ d dlmZ  e¦   «         rddl	Z	 ej
        e¦  «        Z G d„ ded¬	¦  «        Ze ed
¬¦  «         G d„ de¦  «        ¦   «         ¦   «         ZdgZdS )é   )ÚProcessingKwargsÚProcessorMixin)Úauto_docstringÚis_torch_availableÚlogging)Úrequiresé    Nc                   ó   — e Zd ZdddiiZdS )ÚInklingProcessorKwargsÚaudio_kwargsÚload_audio_backendÚ
torchaudioN)Ú__name__Ú
__module__Ú__qualname__Ú	_defaults© ó    úl/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/inkling/processing_inkling.pyr   r      s"   € € € € € àØ  ,ð
ð€I€I€Ir   r   F)Útotal)Útorch)Úbackendsc                   óÀ   ‡ — e Zd ZeZ	 	 	 	 	 	 	 	 	 	 	 dˆ fd	„	Zdd„Zd„ Zdede	de
fd„Zdede	de
fd„Zedee
         fd„¦   «         Zedee
         fd„¦   «         Zˆ xZS )ÚInklingProcessorNú<|unused_200054|>ú<|unused_200053|>ú<|content_image|>ú<|content_audio_input|>é   ç      Àç       @c                 ó–  •— t          |d¦  «        r|j        n|| _        |                     | j        d¬¦  «        d         | _        t          |d¦  «        r|j        n|| _        |                     | j        d¬¦  «        d         | _        || _        |                     | j        d¬¦  «        d         | _        || _        |                     | j        d¬¦  «        d         | _	        |	| _
        |
| _        || _        t          j        |
||	t          j        ¬¦  «        | _        t#          ¦   «                              ||||¬¦  «         dS )	aS  
        image_token (`str`, *optional*, defaults to `"<|unused_200054|>"`):
            Placeholder token for each image soft-token slot (replaced by image features).
        audio_token (`str`, *optional*, defaults to `"<|unused_200053|>"`):
            Placeholder token for each audio soft-token slot (replaced by audio features).
        image_bos_token (`str`, *optional*, defaults to `"<|content_image|>"`):
            Marker token that begins an image span (kept as an ordinary embedded token).
        audio_bos_token (`str`, *optional*, defaults to `"<|content_audio_input|>"`):
            Marker token that begins an audio span (kept as an ordinary embedded token).
        num_dmel_bins (`int`, *optional*, defaults to 16):
            Number of discrete bins each (clamped) log-mel value is quantized into.
        dmel_min_value (`float`, *optional*, defaults to -7.0):
            Lower clamp bound, in log10 space, used for dMel quantization.
        dmel_max_value (`float`, *optional*, defaults to 2.0):
            Upper clamp bound, in log10 space, used for dMel quantization.
        Úimage_tokenF)Úadd_special_tokensr	   Úaudio_token)Údtype)Úchat_templateN)Úhasattrr#   ÚencodeÚimage_token_idr%   Úaudio_token_idÚimage_bos_tokenÚimage_bos_token_idÚaudio_bos_tokenÚaudio_bos_token_idÚnum_dmel_binsÚdmel_min_valueÚdmel_max_valuer   ÚlinspaceÚfloat64Úbin_centersÚsuperÚ__init__)ÚselfÚfeature_extractorÚimage_processorÚ	tokenizerr'   r#   r%   r,   r.   r0   r1   r2   ÚkwargsÚ	__class__s                €r   r7   zInklingProcessor.__init__)   sK  ø€ õ> 5<¸IÀ}Ñ4UÔ4UÐf˜9Ô0Ð0Ð[fˆÔØ'×.Ò.¨tÔ/?ÐTYÐ.ÑZÔZÐ[\Ô]ˆÔÝ4;¸IÀ}Ñ4UÔ4UÐf˜9Ô0Ð0Ð[fˆÔØ'×.Ò.¨tÔ/?ÐTYÐ.ÑZÔZÐ[\Ô]ˆÔØ.ˆÔØ"+×"2Ò"2°4Ô3GÐ\aÐ"2Ñ"bÔ"bÐcdÔ"eˆÔØ.ˆÔØ"+×"2Ò"2°4Ô3GÐ\aÐ"2Ñ"bÔ"bÐcdÔ"eˆÔð +ˆÔØ,ˆÔØ,ˆÔÝ œ>¨.¸.È-Õ_dÔ_lÐmÑmÔmˆÔå‰Œ×ÒÐ*¨O¸YÐVcÐÑdÔdÐdÐdÐdr   Úinput_featuresútorch.TensorÚreturnc                 ór  — | j                              |j        ¦  «        }|                     t          j        ¦  «                             | j        | j        ¬¦  «        }|                     d¦  «        |z
   	                    ¦   «          
                    d¬¦  «                             t          j        ¦  «        S )N)ÚminÚmaxéÿÿÿÿ)Údim)r5   ÚtoÚdevicer   r4   Úclampr1   r2   Ú	unsqueezeÚabsÚargminÚint32)r8   r>   r5   Úmels       r   Ú_extract_dmel_binsz#InklingProcessor._extract_dmel_binsY   sŽ   € ØÔ&×)Ò)¨.Ô*?Ñ@Ô@ˆØ×Ò¥¤Ñ.Ô.×4Ò4¸Ô9LÐRVÔReÐ4ÑfÔfˆØ—’˜bÑ!Ô! KÑ/×4Ò4Ñ6Ô6×=Ò=À"Ð=ÑEÔE×HÒHÍÌÑUÔUÐUr   c                 óÞ   ‡ ‡—  ‰ j         |fi |¤Ž}‰                      |d         ¦  «        |                     d¦  «        dœŠˆˆ fd„t          t	          |¦  «        ¦  «        D ¦   «         }‰|fS )Nr>   Úinput_features_mask)Úaudio_input_idsÚaudio_input_ids_maskc                 ó>   •— g | ]}‰                      ‰|¬ ¦  «        ‘ŒS ))Ú	audio_idx)Úreplace_audio_token)Ú.0ÚidxÚprocessed_audior8   s     €€r   ú
<listcomp>z3InklingProcessor._process_audio.<locals>.<listcomp>e   s.   ø€ ÐtÐtÐtÐ[^˜d×6Ò6°ÐRUÐ6ÑVÔVÐtÐtÐtr   )r9   rN   ÚgetÚrangeÚlen)r8   Úaudior<   Úaudio_inputsÚaudio_replacementsrX   s   `    @r   Ú_process_audiozInklingProcessor._process_audio^   s”   øø€ Ø-�tÔ-¨eÐ>Ð>°vÐ>Ð>ˆð  $×6Ò6°|ÐDTÔ7UÑVÔVØ$0×$4Ò$4Ð5JÑ$KÔ$Kð
ð 
ˆð uÐtÐtÐtÐtÕbgÕhkÐlqÑhrÔhrÑbsÔbsÐtÑtÔtÐØÐ 2Ð2Ð2r   Úimage_inputsÚ	image_idxc                 ó2   — |d         |         }| j         |z  S ©NÚnum_patches)r#   )r8   ra   rb   Únum_soft_tokenss       r   Úreplace_image_tokenz$InklingProcessor.replace_image_tokenh   s   € Ø& }Ô5°iÔ@ˆØÔ /Ñ1Ð1r   r^   rT   c                 óà   — |                      d¦  «        }|�(t          ||                              ¦   «         ¦  «        }n&t          |d         |         j        d         ¦  «        }| j        |z  S )NrR   rQ   éþÿÿÿ)rZ   ÚintÚsumÚshaper%   )r8   r^   rT   rR   rf   s        r   rU   z$InklingProcessor.replace_audio_tokenl   sm   € Ø+×/Ò/Ð0FÑGÔGÐàÐ+Ý!Ð"6°yÔ"A×"EÒ"EÑ"GÔ"GÑHÔHˆOˆOå! ,Ð/@Ô"AÀ)Ô"LÔ"RÐSUÔ"VÑWÔWˆOØÔ /Ñ1Ð1r   c                 ó   — dgS rd   r   )r8   s    r   Úunused_input_namesz#InklingProcessor.unused_input_namesu   s
   € àˆÐr   c                 óˆ   ‡ — ddg‰ j         j        ¢‰ j        j        ¢}ˆ fd„t                               |¦  «        D ¦   «         S )NrQ   rR   c                 ó&   •— g | ]}|‰j         v¯|‘ŒS r   )rn   )rV   Únamer8   s     €r   rY   z6InklingProcessor.model_input_names.<locals>.<listcomp>�   s&   ø€ Ð]Ð]Ð]˜¸ÀTÔE\Ð9\Ð9\�Ð9\Ð9\Ð9\r   )r:   Úmodel_input_namesr;   ÚdictÚfromkeys)r8   Únamess   ` r   rr   z"InklingProcessor.model_input_namesy   sZ   ø€ ð Ø"ð
ð Ô!Ô3ð
ð Œ^Ô-ð	
ˆð ^Ð]Ð]Ð]¥§¢¨uÑ!5Ô!5Ð]Ñ]Ô]Ð]r   )NNNNr   r   r   r   r   r    r!   )r>   r?   r@   r?   )r   r   r   r   Úvalid_processor_kwargsr7   rN   r`   rs   rj   Ústrrg   rU   ÚpropertyÚlistrn   rr   Ú__classcell__)r=   s   @r   r   r   $   sG  ø€ € € € € ð 4Ðð ØØØØ'Ø'Ø+Ø1ØØØð.eð .eð .eð .eð .eð .eð`Vð Vð Vð Vð
3ð 3ð 3ð2°ð 2Àð 2Èð 2ð 2ð 2ð 2ð2°ð 2Àð 2Èð 2ð 2ð 2ð 2ð ð D¨¤Ið ð ð ñ „Xðð ð^ 4¨¤9ð ^ð ^ð ^ñ „Xð^ð ^ð ^ð ^ð ^r   r   )Úprocessing_utilsr   r   Úutilsr   r   r   Úutils.import_utilsr   r   Ú
get_loggerr   Úloggerr   r   Ú__all__r   r   r   ú<module>r�      s  ðð  AÐ @Ð @Ð @Ð @Ð @Ð @Ð @Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø *Ð *Ð *Ð *Ð *Ð *ð ÐÑÔð Ø€L€L€Lð 
ˆÔ	˜HÑ	%Ô	%€ðð ð ð ð Ð-°Uð ñ ô ð ð Ø	€�:ÐÑÔð[^ð [^ð [^ð [^ð [^�~ñ [^ô [^ñ Ôñ „ð[^ð| Ð
€€€r   