§
    ™ŠtjÏ  ã                  óè   — U d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
 d dlZd dlmZ  ej        e¦  «        Zg d¢Zded<   ej        dd„¦   «         Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS )é    )ÚannotationsN)Ú	Generator)ÚPackageNotFoundErrorÚmetadata)Úis_torch_npu_available)))ÚpillowÚpilú-pip install -U "sentence-transformers[image]"))Ú
read_videozQpip install -U "sentence-transformers[video]"  # or [audio] for audio-only models))Útorchvisionr
   ))Ú
torchcodeczpip install -U torchcodec))Ú	soundfileÚlibrosaz-pip install -U "sentence-transformers[audio]"z!list[tuple[tuple[str, ...], str]]Ú_DEPENDENCY_EXTRA_HINTSÚreturnúGenerator[None, None, None]c               #  óV  ‡K  — 	 dV — dS # t           t          f$ rŒ} t          | ¦  «                             ¦   «         Št          D ]]\  }}t          ˆfd„|D ¦   «         ¦  «        r= t          | ¦  «        t          | ¦  «                             ¦   «         › d|› �¦  «        | ‚Œ^‚ d} ~ ww xY w)zaRe-raise ImportError/AttributeError with an install hint when a multimodal dependency is missing.Nc              3  ó    •K  — | ]}|‰v V — Œ	d S )N© )Ú.0ÚkwÚmsgs     €úd/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sentence_transformers/util/environment.pyú	<genexpr>z-suggest_extra_on_exception.<locals>.<genexpr>#   s'   øè è € Ð0Ð0 �2˜�9Ð0Ð0Ð0Ð0Ð0Ð0ó    z-

To install the required dependencies, run:
)ÚImportErrorÚAttributeErrorÚstrÚlowerr   ÚanyÚtypeÚstrip)ÚeÚkeywordsÚhintr   s      @r   Úsuggest_extra_on_exceptionr&      sÊ   øè è € ðØˆˆˆˆˆøÝ�Ð(ð ð ð Ý�!‰fŒf�lŠl‰nŒnˆÝ5ð 	pð 	p‰NˆH�dÝÐ0Ð0Ð0Ð0 xÐ0Ñ0Ô0Ñ0Ô0ð pØ•d˜1‘g”g¥ Q¡¤§¢¡¤ÐgÐgÐaeÐgÐgÑhÔhÐnoÐoðpàøøøøðøøøs   … ‹B(œBB#Â#B(Úboolc                 óz   — t           j                             ¦   «         ot           j                             ¦   «         S )aP  
    Returns whether ``torch.distributed`` is available and has been initialized.

    The availability check must come first: some PyTorch builds (e.g. ROCm or CPU-only) report
    ``torch.distributed.is_available() == False`` and do not expose APIs like ``is_initialized``, so calling
    them directly raises ``AttributeError``.
    )ÚtorchÚdistributedÚis_availableÚis_initializedr   r   r   Úis_dist_initializedr-   (   s-   € õ Ô×)Ò)Ñ+Ô+ÐRµÔ0A×0PÒ0PÑ0RÔ0RÐRr   r   c                 óÒ  — t           j                             ¦   «         r dt          j        v r t          t          j        d         ¦  «        } nmt          ¦   «         r]t           j                             ¦   «         t           j         	                    ¦   «         k    rt           j         	                    ¦   «         } nd} d| › �S t           j
        j                             ¦   «         rdS t          ¦   «         rdS t          t           d¦  «        r t           j                             ¦   «         rdS t          j                             d¦  «        �ddlm c m} |                     ¦   «         rd	S d
S )aV  
    Returns the name of the device where this module is running on.

    This function only supports single device or basic distributed training setups.
    In distributed mode for cuda device, it uses the rank to assign a specific CUDA device.

    Returns:
        str: Device name, like 'cuda:2', 'mps', 'npu', 'xpu', 'hpu', or 'cpu'
    Ú
LOCAL_RANKr   zcuda:ÚmpsÚnpuÚxpuÚhabana_frameworksNÚhpuÚcpu)r)   Úcudar+   ÚosÚenvironÚintr-   Údevice_countr*   Úget_rankÚbackendsr0   r   Úhasattrr2   Ú	importlibÚutilÚ	find_specÚhabana_frameworks.torch.hpur4   )Ú
local_rankÚhthpus     r   Úget_device_namerD   3   sH  € õ „z×ÒÑ Ô ð Ø�2œ:Ð%Ð%Ý�RœZ¨Ô5Ñ6Ô6ˆJˆJÝ Ñ"Ô"ð 	¥u¤z×'>Ò'>Ñ'@Ô'@Å5ÔCT×C]ÒC]ÑC_ÔC_Ò'_Ð'_ÝÔ*×3Ò3Ñ5Ô5ˆJˆJàˆJØ#�zÐ#Ð#Ð#Ý	ŒÔ	×	(Ò	(Ñ	*Ô	*ð 
ØˆuÝ	Ñ	!Ô	!ð ØˆuÝ	•˜Ñ	Ô	ð ¥5¤9×#9Ò#9Ñ#;Ô#;ð ØˆuÝ	Œ×	!Ò	!Ð"5Ñ	6Ô	6Ð	BØ3Ð3Ð3Ð3Ð3Ð3Ð3Ð3Ð3à×ÒÑÔð 	Ø�5Øˆ5r   Úpackage_nameÚownerc                ó|   — 	 t          | ¦  «        }|d         }|d         | k    o|duo||v S # t          $ r Y dS w xY w)zB
    Checks if a package is available from the correct owner.
    z	Home-pageÚNameNF)r   r   )rE   rF   ÚmetaÚ	home_pages       r   Úcheck_package_availabilityrK   S   sd   € ðÝ˜Ñ%Ô%ˆØ˜Ô%ˆ	Ø�FŒ|˜|Ò+Ð\°	ÀÐ0EÐ\È%ÐS\ÐJ\Ð\øÝð ð ð Øˆuˆuðøøøs   ‚*- ­
;º;c                 ó"   — t          dd¦  «        S )zJ
    Returns True if the Huggingface accelerate library is available.
    Ú
accelerateÚhuggingface©rK   r   r   r   Úis_accelerate_availablerP   _   s   € õ & l°MÑBÔBÐBr   c                 ó"   — t          dd¦  «        S )zH
    Returns True if the Huggingface datasets library is available.
    ÚdatasetsrN   rO   r   r   r   Úis_datasets_availablerS   f   s   € õ & j°-Ñ@Ô@Ð@r   c                 ó:   — t          ¦   «         ot          ¦   «         S )z 
    Returns True if we have the required dependencies for training Sentence
    Transformers models, i.e. Huggingface datasets and Huggingface accelerate.
    )rP   rS   r   r   r   Úis_training_availablerU   m   s   € õ
 #Ñ$Ô$Ð@Õ)>Ñ)@Ô)@Ð@r   )r   r   )r   r'   )r   r   )rE   r   rF   r   r   r'   )Ú
__future__r   Ú
contextlibr>   Úloggingr7   Úcollections.abcr   Úimportlib.metadatar   r   r)   Útransformersr   Ú	getLoggerÚ__name__Úloggerr   Ú__annotations__Úcontextmanagerr&   r-   rD   rK   rP   rS   rU   r   r   r   ú<module>ra      sz  ðØ "Ð "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø Ð Ð Ð Ø €€€Ø 	€	€	€	Ø %Ð %Ð %Ð %Ð %Ð %Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =à €€€Ø /Ð /Ð /Ð /Ð /Ð /à	ˆÔ	˜8Ñ	$Ô	$€ð>ð >ð >Ð ð ð ð ñ ð Ôð	ð 	ð 	ñ Ôð	ðSð Sð Sð Sðð ð ð ð@	ð 	ð 	ð 	ðCð Cð Cð CðAð Að Að AðAð Að Að Að Að Ar   