§
    �Štj/J  ã            	       óˆ  — U d Z ddlZddlZddlmZ ddlmZ ddlZddlmZ ddl	m
Z
mZ ddlmZ ddlmZ d	d
lmZ ej        Zej        ZdZeej        j        df         ed<   dag aeeeg df         ee         f                  ed<    ej        ¦   «         Z ej        ¦   «         Z  e¦   «         a! e"ej        d¦  «        rej        j#        Z$nde%de%fd„Z$ e"ej        d¦  «        rej        j&        Z'nde%de%fd„Z'd„ Z(d„ Z)d„ Z*de+fd„Z,dJd„Z- G d„ de.¦  «        Z/de+fd„Z0de+fd„Z1dKdeddfd„Z2de%fd „Z3de%fd!„Z4dKdedefd"„Z5dKdedefd#„Z6	 dLd&edz  d'ed(e%ddfd)„Z7de8eef         fd*„Z9d+ee%e%e%e%gdf         ddfd,„Z:dMd.e+fd/„Z;dKdedee%e%f         fd0„Z<dJd1„Z=d2efd3„Z>deddfd4„Z?dKdede8eef         fd5„Z@ G d6„ d¦  «        ZA G d7„ d8¦  «        ZBd9„ ZCd2edz  deBfd:„ZDdNdedefd<„ZEdee         fd=„ZFdNd>ededdfd?„ZGd@ee         ddfdA„ZHdBe%ddfdC„ZIdBe%ddfdD„ZJde%fdE„ZKde%fdF„ZLde%fdG„ZMd	dHlNT d	dHlOT g dI¢ZPdS )OzH
This package enables an interface for accessing MTIA backend in python
é    N)ÚCallable)ÚAny)ÚTensor)Ú	is_fbcodeÚis_prod)Ú_LazySeedTracker)ÚDeviceé   )Ú_get_device_index© .Údefault_generatorsFÚ_queued_callsÚ_mtia_exchangeDeviceÚdeviceÚreturnc                 ó0   — | dk     rdS t          d¦  «        ‚©Nr   éÿÿÿÿz)PyTorch was compiled without MTIA support©ÚRuntimeError©r   s    úQ/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/mtia/__init__.pyÚ_exchange_devicer   )   ó   € Ø�AŠ:ˆ:Ø�2ÝÐFÑGÔGÐGó    Ú_mtia_maybeExchangeDevicec                 ó0   — | dk     rdS t          d¦  «        ‚r   r   r   s    r   Ú_maybe_exchange_devicer   3   r   r   c                  ó"   — t          ¦   «          d S ©N)Ú
_lazy_initr   r   r   Úinitr"   9   s   € Ý�L„L€L€L€Lr   c                  ó.   — t           ot          ¦   «          S )z9Return whether PyTorch's MTIA state has been initialized.)Ú_initializedÚ_is_in_bad_forkr   r   r   Úis_initializedr&   =   s   € åÐ1¥Ñ 1Ô 1Ð1Ð1r   c                 óô  — t           5  t          ¦   «         r | ¦   «         cd d d ¦  «         S |                     dd¦  «        r-t                               | t          j        ¦   «         ¦  «         np|                     dd¦  «        r-t                               | t          j        ¦   «         ¦  «         n-t           	                    | t          j        ¦   «         f¦  «         d d d ¦  «         d S # 1 swxY w Y   d S )NÚseed_allFÚseed)
Ú_initialization_lockr&   ÚgetÚ_lazy_seed_trackerÚqueue_seed_allÚ	tracebackÚformat_stackÚ
queue_seedr   Úappend)ÚcallableÚkwargss     r   Ú
_lazy_callr4   B   s^  € Ý	ð 
Kð 
KÝÑÔð 		KØ�8‘:”:ð
Kð 
Kð 
Kð 
Kñ 
Kô 
Kð 
Kð 
Kð
 �zŠz˜* eÑ,Ô,ð KÝ"×1Ò1°(½IÔ<RÑ<TÔ<TÑUÔUÐUÐUØ—’˜F EÑ*Ô*ð KÝ"×-Ò-¨h½	Ô8NÑ8PÔ8PÑQÔQÐQÐQå×$Ò$ hµ	Ô0FÑ0HÔ0HÐ%IÑJÔJÐJð
Kð 
Kð 
Kñ 
Kô 
Kð 
Kð 
Kð 
Kð 
Kð 
Kð 
Kð 
Køøøð 
Kð 
Kð 
Kð 
Kð 
Kð 
Ks   ˆC-­B3C-Ã-C1Ã4C1c                  ó>   — t           j                             ¦   «         S r    )ÚtorchÚ_CÚ_mtia_isInBadForkr   r   r   r%   r%   P   s   € ÝŒ8×%Ò%Ñ'Ô'Ð'r   c            	      óÂ  — t          ¦   «         st          t          d¦  «        rd S t          5  t          ¦   «         r	 d d d ¦  «         d S t	          ¦   «         rt          d¦  «        ‚t          ¦   «         st          d¦  «        ‚t          ¦   «         r:t          ¦   «         r,	 ddl
m}  |                      ¦   «          n# t          $ r Y nw xY wt          j                             ¦   «          dt          _        t$                               d„ t(                               ¦   «         D ¦   «         ¦  «         	 t$          D ]Z\  }}	  |¦   «          Œ# t,          $ r=}dt/          |¦  «        › d	d
                     |¦  «        › �}t3          |¦  «        |‚d }~ww xY w	 t5          t          d¦  «         n# t5          t          d¦  «         w xY wdad d d ¦  «         d S # 1 swxY w Y   d S )NÚis_initializingzwCannot re-initialize MTIA in forked subprocess. To use MTIA with multiprocessing, you must use the 'spawn' start methodzÖTorch not compiled with MTIA enabled. Ensure you have `import mtia.host_runtime.torch_mtia.dynamic_library` in your python src file and include `//mtia/host_runtime/torch_mtia:torch_mtia` as your target dependency!r   )Úcxx_resource_managerTc              3   ó   K  — | ]}|¯|V — Œ	d S r    r   )Ú.0Úcallss     r   ú	<genexpr>z_lazy_init.<locals>.<genexpr>�   s(   è è € ÐXÐX uÐRWÐX˜UÐXÐXÐXÐXÐXÐXr   z6MTIA call failed lazily at initialization with error: z(

MTIA call was originally invoked at:

Ú )r&   ÚhasattrÚ_tlsr*   r%   r   Ú_is_compiledÚAssertionErrorr   r   Úlibfb.py.cxx_resourcesr;   ÚinstallÚModuleNotFoundErrorr6   r7   Ú
_mtia_initr:   r   Úextendr,   Ú	get_callsÚ	ExceptionÚstrÚjoinÚDeferredMtiaCallErrorÚdelattrr$   )r;   Úqueued_callÚorig_tracebackÚeÚmsgs        r   r!   r!   T   s   € åÑÔð �7¥4Ð):Ñ;Ô;ð ØˆÝ	ð 7ð 7õ ÑÔð 	Øð7ð 7ð 7ñ 7ô 7ð 7ð 7ð 7õ ÑÔð 	ÝðIñô ð õ ‰~Œ~ð 	Ý ð*ñô ð õ ‰;Œ;ð 	�7™9œ9ð 	ðØGÐGÐGÐGÐGÐGà$×,Ò,Ñ.Ô.Ð.Ð.øÝ&ð ð ð à�ðøøøõ 	Œ×ÒÑÔÐð  $�Ôå×ÒÐXÐXÕ0B×0LÒ0LÑ0NÔ0NÐXÑXÔXÑXÔXÐXð	-Ý/<ð <ð <Ñ+�˜^ð<Ø�K‘M”M�M�MøÝ ð <ð <ð <ð]ÕQTÐUVÑQWÔQWð ]ð ]ØCEÇ7Â7È>ÑCZÔCZð]ð ]ð õ 0°Ñ4Ô4¸!Ð;øøøøð<øøøð<õ •DÐ+Ñ,Ô,Ð,Ð,ø�G•DÐ+Ñ,Ô,Ð,Ð,øøøØˆðo7ð 7ð 7ñ 7ô 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7øøøð 7ð 7ð 7ð 7ð 7ð 7sy   ­GÁ
AGÂ!B<Â;GÂ<
C	ÃGÃC	Ã	A(GÄ2F+Ä?
E
Å	F+Å

FÅ8FÆFÆF+ÆGÆ+GÇGÇGÇGc                   ó   — e Zd ZdS )rN   N)Ú__name__Ú
__module__Ú__qualname__r   r   r   rN   rN   ’   s   € € € € € Ø€Dr   rN   c                  ó>   — t           j                             ¦   «         S )z*Return true if compiled with MTIA support.)r6   r7   Ú_mtia_isBuiltr   r   r   rC   rC   –   s   € åŒ8×!Ò!Ñ#Ô#Ð#r   c                  óF   — t          ¦   «         sdS t          ¦   «         dk    S )z'Return true if MTIA device is availableFr   )rC   Údevice_countr   r   r   Úis_availabler\   ›   s"   € å‰>Œ>ð Øˆuå‰>Œ>˜AÒÐr   c                 ó°   — t           j                             | ¦  «        5  t           j                             ¦   «         cddd¦  «         S # 1 swxY w Y   dS )z?Waits for all jobs in all streams on a MTIA device to complete.N)r6   Úmtiar   r7   Ú_mtia_deviceSynchronizer   s    r   Úsynchronizer`   £   s�   € å	Œ×	Ò	˜6Ñ	"Ô	"ð 2ð 2ÝŒx×/Ò/Ñ1Ô1ð2ð 2ð 2ð 2ñ 2ô 2ð 2ð 2ð 2ð 2ð 2ð 2øøøð 2ð 2ð 2ð 2ð 2ð 2s    AÁAÁAc                  ó>   — t           j                             ¦   «         S )z,Return the number of MTIA devices available.)r6   r7   Ú_mtia_getDeviceCountr   r   r   r[   r[   ©   s   € åŒ8×(Ò(Ñ*Ô*Ð*r   c                  ó>   — t           j                             ¦   «         S )z0Return the index of a currently selected device.)r6   r7   Ú_mtia_getDevicer   r   r   Úcurrent_devicere   ®   s   € õ Œ8×#Ò#Ñ%Ô%Ð%r   c                 ób   — t          | d¬¦  «        }t          j                             |¦  «        S )aS  Return the currently selected :class:`Stream` for a given device.

    Args:
        device (torch.device or int, optional): selected device. Returns
            the currently selected :class:`Stream` for the current device, given
            by :func:`~torch.mtia.current_device`, if :attr:`device` is ``None``
            (default).
    T©Úoptional)r   r6   r7   Ú_mtia_getCurrentStream)r   Ú
device_idxs     r   Úcurrent_streamrk   ´   s,   € õ # 6°DÐ9Ñ9Ô9€JÝŒ8×*Ò*¨:Ñ6Ô6Ð6r   c                 ó^   — t           j                             t          | d¬¦  «        ¦  «        S )a=  Return the default :class:`Stream` for a given device.

    Args:
        device (torch.device or int, optional): selected device. Returns
            the default :class:`Stream` for the current device, given by
            :func:`~torch.mtia.current_device`, if :attr:`device` is ``None``
            (default).
    Trg   )r6   r7   Ú_mtia_getDefaultStreamr   r   s    r   Údefault_streamrn   Á   s(   € õ Œ8×*Ò*Õ+<¸VÈdÐ+SÑ+SÔ+SÑTÔTÐTr   ÚallÚpythonÚenabledÚstacksÚmax_entriesc                 óh   — t          ¦   «         sdS t          j                             | ||¦  «         dS )a•  Enable/Disable the memory profiler on MTIA allocator

    Args:
        enabled (all or state, optional) selected device. Returns
            statistics for the current device, given by current_device(),
            if device is None (default).

        stacks ("python" or "cpp", optional). Select the stack trace to record.

        max_entries (int, optional). Maximum number of entries to record.
    N)r&   r6   r7   Ú_mtia_recordMemoryHistory)rq   rr   rs   s      r   Úrecord_memory_historyrv   Í   s7   € õ ÑÔð ØˆÝ	„H×&Ò& w°¸ÑDÔDÐDÐDÐDr   c                  ó>   — t           j                             ¦   «         S )z4Return a dictionary of MTIA memory allocator history)r6   r7   Ú_mtia_memorySnapshotr   r   r   Úsnapshotry   à   s   € õ Œ8×(Ò(Ñ*Ô*Ð*r   Úobserverc                 óD   — t           j                             | ¦  «         dS )z9Attach an out-of-memory observer to MTIA memory allocatorN)r6   r7   Ú_mtia_attachOutOfMemoryObserver)rz   s    r   Úattach_out_of_memory_observerr}   æ   s    € õ 
„H×,Ò,¨XÑ6Ô6Ð6Ð6Ð6r   TÚincluding_emulationc                 ó   — dS )zLReturn a bool indicating if the current MTIA device supports dtype bfloat16.Tr   )r~   s    r   Úis_bf16_supportedr€   í   s   € àˆ4r   c                 ó^   — t           j                             t          | d¬¦  «        ¦  «        S )a  Return capability of a given device as a tuple of (major version, minor version).

    Args:
        device (torch.device or int, optional) selected device. Returns
            statistics for the current device, given by current_device(),
            if device is None (default).
    Trg   )r6   r7   Ú_mtia_getDeviceCapabilityr   r   s    r   Úget_device_capabilityrƒ   ò   ó)   € õ Œ8×-Ò-Õ.?ÀÐQUÐ.VÑ.VÔ.VÑWÔWÐWr   c                  ó>   — t           j                             ¦   «         S )zEmpty the MTIA device cache.)r6   r7   Ú_mtia_emptyCacher   r   r   Úempty_cacher‡   ý   s   € åŒ8×$Ò$Ñ&Ô&Ð&r   Ústreamc                 óL   — | €dS t           j                             | ¦  «         dS )a  Set the current stream. This is a wrapper API to set the stream.
        Usage of this function is discouraged in favor of the ``stream``
        context manager.

    Args:
        stream (Stream): selected stream. This function is a no-op
            if this argument is ``None``.
    N)r6   r7   Ú_mtia_setCurrentStream©rˆ   s    r   Ú
set_streamrŒ     s*   € ð €~ØˆÝ	„H×#Ò# FÑ+Ô+Ð+Ð+Ð+r   c                 ór   — t          | ¦  «        } | dk    r!t          j                             | ¦  «         dS dS )z¡Set the current device.

    Args:
        device (torch.device or int): selected device. This function is a no-op
            if this argument is negative.
    r   N)r   r6   r7   Ú_mtia_setDevicer   s    r   Ú
set_devicer�     s=   € õ ˜vÑ&Ô&€FØ�‚{€{åŒ× Ò  Ñ(Ô(Ð(Ð(Ð(ð €{r   c                 ó^   — t           j                             t          | d¬¦  «        ¦  «        S )zøReturn a dictionary of MTIA device properties

    Args:
        device (torch.device or int, optional) selected device. Returns
            statistics for the current device, given by current_device(),
            if device is None (default).
    Trg   )r6   r7   Ú_mtia_getDevicePropertiesr   r   s    r   Úget_device_propertiesr’     r„   r   c                   ó8   — e Zd ZdZd efd„Zd„ Zdededefd„ZdS )	r   zÌContext-manager that changes the selected device.

    Args:
        device (torch.device or int): device index to select. It's a no-op if
            this argument is a negative integer or ``None``.
    c                 ó@   — t          |d¬¦  «        | _        d| _        d S )NTrg   r   )r   ÚidxÚprev_idx)Úselfr   s     r   Ú__init__zdevice.__init__0  s!   € Ý$ V°dÐ;Ñ;Ô;ˆŒØˆŒˆˆr   c                 óX   — t           j                             | j        ¦  «        | _        d S r    )r6   r7   r   r•   r–   )r—   s    r   Ú	__enter__zdevice.__enter__4  s   € åœ×:Ò:¸4¼8ÑDÔDˆŒˆˆr   ÚtypeÚvaluer.   c                 óX   — t           j                             | j        ¦  «        | _        dS )NF)r6   r7   r   r–   r•   )r—   r›   rœ   r.   s       r   Ú__exit__zdevice.__exit__8  s    € å”8×5Ò5°d´mÑDÔDˆŒØˆur   N)rU   rV   rW   Ú__doc__r   r˜   rš   rž   r   r   r   r   r   (  st   € € € € € ðð ð˜sð ð ð ð ðEð Eð Eð˜Sð ¨ð ¸ð ð ð ð ð ð r   c                   óP   — e Zd ZU dZedz  ed<   dedz  fd„Zd„ Zdeded	efd
„Z	dS )ÚStreamContexta  Context-manager that selects a given stream.

    All MTIA kernels queued within its context will be enqueued on a selected
    stream.

    Args:
        Stream (Stream): selected stream. This manager is a no-op if it's
            ``None``.
    .. note:: Streams are per-device.
    NÚ
cur_streamrˆ   c                 ó´  — d | _         || _        t          d d¦  «        | _        t          j                             ¦   «         s| j        €d| _        t          j                             ¦   «         sd nt          j                             d ¦  «        | _	        t          j                             ¦   «         sd nt          j                             d ¦  «        | _
        d S )NTr   )r¢   rˆ   r   r•   r6   ÚjitÚis_scriptingr^   rn   Úsrc_prev_streamÚdst_prev_stream)r—   rˆ   s     r   r˜   zStreamContext.__init__L  s¶   € ØˆŒØˆŒÝ$ T¨4Ñ0Ô0ˆŒÝŒy×%Ò%Ñ'Ô'ð 	ØŒxÐØ�”õ œ	×.Ò.Ñ0Ô0ÐUˆDˆDµe´j×6OÒ6OÐPTÑ6UÔ6Uð 	Ôõ œ	×.Ò.Ñ0Ô0ÐUˆDˆDµe´j×6OÒ6OÐPTÑ6UÔ6Uð 	ÔÐÐr   c                 óŒ  — | j         }|�| j        dk    rd S t          j                             d ¦  «        | _        | j        j        |j        k    rUt          |j        ¦  «        5  t          j                             |j        ¦  «        | _        d d d ¦  «         n# 1 swxY w Y   t          j                             |¦  «         d S ©Nr   )	rˆ   r•   r6   r^   rk   r¦   r   r§   rŒ   )r—   r¢   s     r   rš   zStreamContext.__enter__[  sú   € à”[ˆ
àÐ ¤¨R¢ ØˆFÝ$œz×8Ò8¸Ñ>Ô>ˆÔð ÔÔ&¨*Ô*;Ò;Ð;Ý˜
Ô)Ñ*Ô*ð Tð TÝ',¤z×'@Ò'@ÀÔARÑ'SÔ'S�Ô$ðTð Tð Tñ Tô Tð Tð Tð Tð Tð Tð Tøøøð Tð Tð Tð TåŒ
×Ò˜jÑ)Ô)Ð)Ð)Ð)s   Á$*BÂBÂ!Br›   rœ   r.   c                 óì   — | j         }|�| j        dk    rd S | j        j        |j        k    r$t          j                             | j        ¦  «         t          j                             | j        ¦  «         d S r©   )rˆ   r•   r¦   r   r6   r^   rŒ   r§   )r—   r›   rœ   r.   r¢   s        r   rž   zStreamContext.__exit__j  sl   € à”[ˆ
àÐ ¤¨R¢ ØˆFð ÔÔ&¨*Ô*;Ò;Ð;ÝŒJ×!Ò! $Ô"6Ñ7Ô7Ð7ÝŒ
×Ò˜dÔ2Ñ3Ô3Ð3Ð3Ð3r   )
rU   rV   rW   rŸ   ÚStreamÚ__annotations__r˜   rš   r   rž   r   r   r   r¡   r¡   >  s‰   € € € € € € ð	ð 	ð ˜‘ÐÐÑð
˜v¨™}ð 
ð 
ð 
ð 
ð*ð *ð *ð4˜Sð 4¨ð 4¸ð 4ð 4ð 4ð 4ð 4ð 4r   r¡   c                 óH   — t           j                             | ||¦  «         dS )zæset stream specified by the stream id, device index and
        device type

    Args: stream_id (int): stream id in stream pool
          device_index (int): device index in topo
          device_type (int): enum device type
    N)r6   r7   Ú_mtia_setStream)Ú	stream_idÚdevice_indexÚdevice_types      r   Ú_set_stream_by_idr²   x  s$   € õ 
„H×Ò˜Y¨°kÑBÔBÐBÐBÐBr   c                 ó    — t          | ¦  «        S )a,  Wrap around the Context-manager StreamContext that selects a given stream.

    Arguments:
        stream (Stream): selected stream. This manager is a no-op if it's
            ``None``.
    .. note:: In eager mode stream is of type Stream class while in JIT it doesn't support torch.mtia.stream
    )r¡   r‹   s    r   rˆ   rˆ   ƒ  s   € õ ˜Ñ Ô Ð r   r^   c                 ó¢   — t          ¦   «          t          | d¬¦  «        }|€t          ¦   «         }t          |         }|                     ¦   «         S )a[  Returns the random number generator state of the specified MTIA device as a ByteTensor.

    Args:
        device (torch.device or int, optional): The device to return the RNG state of.
            Default: ``'mtia'`` (i.e., ``torch.device('mtia')``, the current mtia device).

    .. warning::
        This function eagerly initializes MTIA.
    Trg   )r!   r   re   r   Ú	get_state)r   r•   Údefault_generators      r   Úget_rng_stater·   Ž  sL   € õ �L„L€LÝ
˜F¨TÐ
2Ñ
2Ô
2€CØ
€{ÝÑÔˆÝ*¨3Ô/ÐØ×&Ò&Ñ(Ô(Ð(r   c                  óP   — d„ t          t          ¦   «         ¦  «        D ¦   «         } | S )zRReturns a list of ByteTensor representing the random number states of all devices.c                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )r·   )r=   Úis     r   ú
<listcomp>z%get_rng_state_all.<locals>.<listcomp>¢  s    € Ð?Ð?Ð? A�}˜QÑÔÐ?Ð?Ð?r   )Úranger[   )Úresultss    r   Úget_rng_state_allr¾      s&   € à?Ð?­­|©~¬~Ñ)>Ô)>Ð?Ñ?Ô?€GØ€Nr   Ú	new_statec                 ó>  ‡ ‡— t          ¦   «         sVt          j                             ¦   «         5  ‰                      t          j        ¬¦  «        Š ddd¦  «         n# 1 swxY w Y   t          |d¬¦  «        Š‰€t          ¦   «         Šˆˆ fd„}t          |¦  «         dS )a8  Sets the random number generator state of the specified MTIA device.

    Args:
        new_state (torch.ByteTensor): The desired state
        device (torch.device or int, optional): The device to set the RNG state.
            Default: ``'mtia'`` (i.e., ``torch.device('mtia')``, the current mtia device).
    )Úmemory_formatNTrg   c                  óL   •— t           ‰         } |                      ‰¦  «         d S r    )r   Ú	set_state)r¶   r•   r¿   s    €€r   Úcbzset_rng_state.<locals>.cb¸  s(   ø€ Ý.¨sÔ3ÐØ×#Ò# IÑ.Ô.Ð.Ð.Ð.r   )	r&   r6   r7   Ú_DisableFuncTorchÚcloneÚcontiguous_formatr   re   r4   )r¿   r   rÄ   r•   s   `  @r   Úset_rng_staterÈ   ¦  sú   øø€ õ ÑÔð OÝŒX×'Ò'Ñ)Ô)ð 	Oð 	Oð "ŸšµeÔ6M˜ÑNÔNˆIð	Oð 	Oð 	Oñ 	Oô 	Oð 	Oð 	Oð 	Oð 	Oð 	Oð 	Oøøøð 	Oð 	Oð 	Oð 	Oõ
 ˜F¨TÐ
2Ñ
2Ô
2€CØ
€{ÝÑÔˆð/ð /ð /ð /ð /ð /õ ˆr�N„N€N€N€Ns   ¯!AÁA Á#A Ú
new_statesc                 óP   — t          | ¦  «        D ]\  }}t          ||¦  «         ŒdS )zœSets the random number generator state of all devices.

    Args:
        new_states (Iterable of torch.ByteTensor): The desired state for each device.
    N)Ú	enumeraterÈ   )rÉ   rº   Ústates      r   Úset_rng_state_allrÍ   ¿  s<   € õ ˜jÑ)Ô)ð  ð  ‰ˆˆ5Ý�e˜QÑÔÐÐð ð  r   r)   c                 óR   ‡ — t          ‰ ¦  «        Š ˆ fd„}t          |d¬¦  «         dS )a‘  Sets the seed for generating random numbers for the current MTIA device.
    It's safe to call this function if MTIA is not available; in that case, it is silently ignored.

    Args:
        seed (int): The desired seed.

    .. warning::
        If you are working with a multi-GPU model, this function is insufficient
        to get determinism.  To seed all GPUs, use :func:`manual_seed_all`.
    c                  óh   •— t          ¦   «         } t          |          }|                     ‰¦  «         d S r    )re   r   Úmanual_seed)r•   r¶   r)   s     €r   rÄ   zmanual_seed.<locals>.cbÖ  s3   ø€ ÝÑÔˆÝ.¨sÔ3ÐØ×%Ò% dÑ+Ô+Ð+Ð+Ð+r   T©r)   N©Úintr4   ©r)   rÄ   s   ` r   rÐ   rÐ   É  sD   ø€ õ ˆt‰9Œ9€Dð,ð ,ð ,ð ,ð ,õ
 ˆr˜ÐÑÔÐÐÐr   c                 óR   ‡ — t          ‰ ¦  «        Š ˆ fd„}t          |d¬¦  «         dS )zÚSets the seed for generating random numbers on all MTIA devices.
    It's safe to call this function if MTIA is not available; in that case, it is silently ignored.

    Args:
        seed (int): The desired seed.
    c                  óˆ   •— t          t          ¦   «         ¦  «        D ]$} t          |          }|                     ‰¦  «         Œ%d S r    )r¼   r[   r   rÐ   )rº   r¶   r)   s     €r   rÄ   zmanual_seed_all.<locals>.cbç  sJ   ø€ Ý•|‘~”~Ñ&Ô&ð 	0ð 	0ˆAÝ 2°1Ô 5ÐØ×)Ò)¨$Ñ/Ô/Ð/Ð/ð	0ð 	0r   T©r(   NrÒ   rÔ   s   ` r   Úmanual_seed_allrØ   Þ  sD   ø€ õ ˆt‰9Œ9€Dð0ð 0ð 0ð 0ð 0õ
 ˆr˜DÐ!Ñ!Ô!Ð!Ð!Ð!r   c                  ó*   — d„ } t          | d¬¦  «        S )ax  Sets the seed for generating random numbers to a random number for the current MTIA device.
    It's safe to call this function if MTIA is not available; in that case, it is silently ignored.

    .. warning::
        If you are working with a multi-GPU model, this function will only initialize
        the seed on one GPU.  To initialize all GPUs, use :func:`seed_all`.
    c                  ó`   — t          ¦   «         } t          |          }|                     ¦   «         S r    )re   r   r)   )r•   r¶   s     r   rÄ   zseed.<locals>.cbø  s*   € ÝÑÔˆÝ.¨sÔ3ÐØ ×%Ò%Ñ'Ô'Ð'r   TrÑ   ©r4   ©rÄ   s    r   r)   r)   ï  s&   € ð(ð (ð (õ
 �b˜tÐ$Ñ$Ô$Ð$r   c                  ó*   — d„ } t          | d¬¦  «        S )z½Sets the seed for generating random numbers to a random number on all MTIA devices.

    It's safe to call this function if MTIA is not available; in that case, it is silently ignored.
    c                  óÀ   — d} d}t          t          ¦   «         ¦  «        D ]=}t          |         }|s|                     ¦   «         } d}Œ(|                     | ¦  «         Œ>| S )Nr   FT)r¼   r[   r   r)   rÐ   )Úrandom_seedÚseededrº   r¶   s       r   rÄ   zseed_all.<locals>.cb  so   € ØˆØˆÝ•|‘~”~Ñ&Ô&ð 	;ð 	;ˆAÝ 2°1Ô 5ÐØð ;Ø/×4Ò4Ñ6Ô6�Ø��à!×-Ò-¨kÑ:Ô:Ð:Ð:ØÐr   Tr×   rÛ   rÜ   s    r   r(   r(      s&   € ð
ð 
ð 
õ �b 4Ð(Ñ(Ô(Ð(r   c                  óx   — t          ¦   «          t          ¦   «         } t          |                               ¦   «         S )z‚Returns the current random seed of the current MTIA device.

    .. warning::
        This function eagerly initializes MTIA.
    )r!   re   r   Úinitial_seed)r•   s    r   râ   râ     s/   € õ �L„L€LÝ
Ñ
Ô
€CÝ˜cÔ"×/Ò/Ñ1Ô1Ð1r   )Ú*)#r"   r\   r&   r`   r[   re   rk   rn   Úmemory_statsÚmax_memory_allocatedÚmemory_allocatedÚreset_peak_memory_statsrƒ   r’   rv   ry   r}   r‡   r�   rŒ   rˆ   r   rÈ   r·   rÍ   r¾   rÐ   rØ   r)   r(   râ   r€   Ú	MTIAGraphÚgraphÚgraph_pool_handle)r   Nr    )ro   rp   r   )T)r^   )QrŸ   Ú	threadingr.   Úcollections.abcr   Útypingr   r6   r   Útorch._environmentr   r   Útorch._utilsr   Útorch.typesr	   Ú_utilsr   ÚEventr«   r   Útupler7   Ú	Generatorr¬   r$   r   ÚlistrL   ÚlocalrB   ÚLockr*   r,   rA   r   r   rÓ   r   r   r"   r&   r4   Úboolr%   r!   rK   rN   rC   r\   r`   r[   re   rk   rn   rv   Údictry   r}   r€   rƒ   r‡   rŒ   r�   r’   r   r¡   r²   rˆ   r·   r¾   rÈ   rÍ   rÐ   rØ   r)   r(   râ   ÚmemoryÚ
mtia_graphÚ__all__r   r   r   ú<module>rý      sÛ  ððð ð ð Ð Ð Ð Ø Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð à €€€Ø Ð Ð Ð Ð Ð Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð à %Ð %Ð %Ð %Ð %Ð %ð 	Œ€Ø	Œ€ð 68Ð �E˜%œ(Ô,¨cÐ1Ô2Ð 7Ð 7Ñ 7ð €ð ð ˆtØ	ˆ(�2�t�8Ô
˜d 3œiÐ
'Ô(ôð ð ñ ð €y„ÑÔ€Ø%�y”~Ñ'Ô'Ð Ø%Ð%Ñ'Ô'Ð ð €7ˆ5Œ8Ð+Ñ,Ô,ð HØ”xÔ4ÐÐðH ð H¨ð Hð Hð Hð Hð €7ˆ5Œ8Ð0Ñ1Ô1ð HØ"œXÔ?ÐÐðH sð H¨sð Hð Hð Hð Hðð ð ð2ð 2ð 2ð
Kð Kð Kð(˜ð (ð (ð (ð (ð;ð ;ð ;ð ;ð|	ð 	ð 	ð 	ð 	˜Iñ 	ô 	ð 	ð$�dð $ð $ð $ð $ð
�dð ð ð ð ð2ð 2˜ð 2¨$ð 2ð 2ð 2ð 2ð+�cð +ð +ð +ð +ð
&˜ð &ð &ð &ð &ð
7ð 
7˜6ð 
7¨Vð 
7ð 
7ð 
7ð 
7ð	Uð 	U˜6ð 	U¨Vð 	Uð 	Uð 	Uð 	Uð MNðEð EØ�4‰ZðEØ),ðEØFIðEà	ðEð Eð Eð Eð&+�$�s˜C�x”.ð +ð +ð +ð +ð7Ø˜˜S # sÐ+¨TÐ1Ô2ð7à	ð7ð 7ð 7ð 7ðð ¨4ð ð ð ð ð
Xð X &ð X°E¸#¸s¸(´Oð Xð Xð Xð Xð'ð 'ð 'ð 'ð
,�vð ,ð ,ð ,ð ,ð
)�vð 
) $ð 
)ð 
)ð 
)ð 
)ðXð X &ð X°D¸¸c¸´Nð Xð Xð Xð Xðð ð ð ð ñ ô ð ð,74ð 74ð 74ð 74ð 74ñ 74ô 74ð 74ðtCð Cð Cð!�6˜D‘=ð ! ]ð !ð !ð !ð !ð)ð )˜&ð )¨fð )ð )ð )ð )ð$˜4 œ<ð ð ð ð ðð ˜Vð ¨Vð Àð ð ð ð ð2  $ v¤,ð  °4ð  ð  ð  ð  ð�cð ˜dð ð ð ð ð*"˜#ð " $ð "ð "ð "ð "ð"%ˆcð %ð %ð %ð %ð")�#ð )ð )ð )ð )ð*2�cð 2ð 2ð 2ð 2ð Ð Ð Ð Ø Ð Ð Ð ð$ð $ð $€€€r   