§
    �Štj¢  ã                   ó  — d dl mZ d dlZd dlmZ ddlmZmZmZmZm	Z	 dde
ez  ej        z  defd	„Zdee         fd
„Zddede
ez  ej        z  ddfd„Zdee         ddfd„Zde
ddfd„Zde
ddfd„Zdd„Zdd„Zde
fd„Zg d¢ZdS )é    )ÚIterableN)ÚTensoré   )Ú
_lazy_callÚ
_lazy_initÚcurrent_deviceÚdevice_countÚis_initializedÚxpuÚdeviceÚreturnc                 óJ  — t          ¦   «          t          | t          ¦  «        rt          j        | ¦  «        } n*t          | t
          ¦  «        rt          j        d| ¦  «        } | j        }|€t          ¦   «         }t          j        j	        |         }| 
                    ¦   «         S )aN  Return the random number generator state of the specified GPU as a ByteTensor.

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

    .. warning::
        This function eagerly initializes XPU.
    r   )r   Ú
isinstanceÚstrÚtorchr   ÚintÚindexr   r   Údefault_generatorsÚ	get_state)r   ÚidxÚdefault_generators      úN/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/xpu/random.pyÚget_rng_stater   
   sŒ   € õ �L„L€LÝ�&�#ÑÔð -Ý”˜fÑ%Ô%ˆˆÝ	�F�CÑ	 Ô	 ð -Ý”˜e VÑ,Ô,ˆØ
Œ,€CØ
€{ÝÑÔˆÝœ	Ô4°SÔ9ÐØ×&Ò&Ñ(Ô(Ð(ó    c                  óP   — d„ t          t          ¦   «         ¦  «        D ¦   «         } | S )zQReturn a list of ByteTensor representing the random number states of all devices.c                 ó,   — g | ]}t          |¦  «        ‘ŒS © )r   )Ú.0Ú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          ‰t          ¦  «        rt          j        ‰¦  «        Šn*t          ‰t          ¦  «        rt          j        d‰¦  «        Šdˆˆ fd„}t          |¦  «         dS )a,  Set the random number generator state of the specified GPU.

    Args:
        new_state (torch.ByteTensor): The desired state
        device (torch.device or int, optional): The device to set the RNG state.
            Default: ``'xpu'`` (i.e., ``torch.device('xpu')``, the current XPU device).
    )Úmemory_formatNr   r   c                  óŽ   •— ‰j         } | €t          ¦   «         } t          j        j        |          }|                     ‰¦  «         d S ©N)r   r   r   r   r   Ú	set_state)r   r   r   r$   s     €€r   Úcbzset_rng_state.<locals>.cb7   sD   ø€ ØŒlˆØˆ;Ý Ñ"Ô"ˆCÝ!œIÔ8¸Ô=ÐØ×#Ò# IÑ.Ô.Ð.Ð.Ð.r   ©r   N)r
   r   Ú_CÚ_DisableFuncTorchÚcloneÚcontiguous_formatr   r   r   r   r   )r$   r   r*   s   `` r   Úset_rng_stater0   &   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Ñ%Ô%ˆˆÝ	�F�CÑ	 Ô	 ð -Ý”˜e VÑ,Ô,ˆð/ð /ð /ð /ð /ð /ð /õ ˆr�N„N€N€N€Ns   ¯!AÁA Á#A Ú
new_statesc                 óP   — t          | ¦  «        D ]\  }}t          ||¦  «         ŒdS )z›Set the random number generator state of all devices.

    Args:
        new_states (Iterable of torch.ByteTensor): The desired state for each device.
    N)Ú	enumerater0   )r1   r   Ústates      r   Úset_rng_state_allr5   A   s<   € õ ˜jÑ)Ô)ð  ð  ‰ˆˆ5Ý�e˜QÑÔÐÐð ð  r   Úseedc                 óT   ‡ — t          ‰ ¦  «        Š dˆ fd„}t          |d¬¦  «         dS )aˆ  Set the seed for generating random numbers for the current GPU.

    It's safe to call this function if XPU 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`.
    r   Nc                  ó|   •— t          ¦   «         } t          j        j        |          }|                     ‰¦  «         d S r(   )r   r   r   r   Úmanual_seed)r   r   r6   s     €r   r*   zmanual_seed.<locals>.cbY   s8   ø€ ÝÑÔˆÝ!œIÔ8¸Ô=ÐØ×%Ò% dÑ+Ô+Ð+Ð+Ð+r   T)r6   r+   ©r   r   ©r6   r*   s   ` r   r9   r9   K   sI   ø€ õ ˆt‰9Œ9€Dð,ð ,ð ,ð ,ð ,ð ,õ
 ˆr˜ÐÑÔÐÐÐr   c                 óT   ‡ — t          ‰ ¦  «        Š dˆ fd„}t          |d¬¦  «         dS )zÑSet the seed for generating random numbers on all GPUs.

    It's safe to call this function if XPU is not available; in that case, it is silently ignored.

    Args:
        seed (int): The desired seed.
    r   Nc                  óœ   •— t          t          ¦   «         ¦  «        D ].} t          j        j        |          }|                     ‰¦  «         Œ/d S r(   )r!   r	   r   r   r   r9   )r   r   r6   s     €r   r*   zmanual_seed_all.<locals>.cbk   sO   ø€ Ý•|‘~”~Ñ&Ô&ð 	0ð 	0ˆAÝ %¤	Ô <¸QÔ ?ÐØ×)Ò)¨$Ñ/Ô/Ð/Ð/ð	0ð 	0r   T)Úseed_allr+   r:   r;   s   ` r   Úmanual_seed_allr?   a   sI   ø€ õ ˆt‰9Œ9€Dð0ð 0ð 0ð 0ð 0ð 0õ
 ˆr˜DÐ!Ñ!Ô!Ð!Ð!Ð!r   c                  ó,   — dd„} t          | ¦  «         dS )ao  Set the seed for generating random numbers to a random number for the current GPU.

    It's safe to call this function if XPU 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`.
    r   Nc                  óx   — t          ¦   «         } t          j        j        |          }|                     ¦   «          d S r(   )r   r   r   r   r6   ©r   r   s     r   r*   zseed.<locals>.cb}   s5   € ÝÑÔˆÝ!œIÔ8¸Ô=ÐØ×ÒÑ Ô Ð Ð Ð r   r+   ©r   ©r*   s    r   r6   r6   s   s'   € ð!ð !ð !ð !õ
 ˆr�N„N€N€N€Nr   c                  ó,   — dd„} t          | ¦  «         dS )z³Set the seed for generating random numbers to a random number on all GPUs.

    It's safe to call this function if XPU is not available; in that case, it is silently ignored.
    r   Nc                  óü   — d} d}t          t          ¦   «         ¦  «        D ][}t          j        j        |         }|s+|                     ¦   «          |                     ¦   «         } d}ŒF|                     | ¦  «         Œ\d S )Nr   FT)r!   r	   r   r   r   r6   Úinitial_seedr9   )Úrandom_seedÚseededr   r   s       r   r*   zseed_all.<locals>.cb‹   sŠ   € ØˆØˆÝ•|‘~”~Ñ&Ô&ð 	;ð 	;ˆAÝ %¤	Ô <¸QÔ ?ÐØð ;Ø!×&Ò&Ñ(Ô(Ð(Ø/×<Ò<Ñ>Ô>�Ø��à!×-Ò-¨kÑ:Ô:Ð:Ð:ð	;ð 	;r   r+   rC   rD   s    r   r>   r>   …   s'   € ð
;ð 
;ð 
;ð 
;õ ˆr�N„N€N€N€Nr   c                  ó�   — t          ¦   «          t          ¦   «         } t          j        j        |          }|                     ¦   «         S )zxReturn the current random seed of the current GPU.

    .. warning::
        This function eagerly initializes XPU.
    )r   r   r   r   r   rG   rB   s     r   rG   rG   š   s:   € õ �L„L€LÝ
Ñ
Ô
€CÝœ	Ô4°SÔ9ÐØ×)Ò)Ñ+Ô+Ð+r   )	r   r#   r0   r5   r9   r?   r6   r>   rG   )r   r+   )Úcollections.abcr   r   r   Ú r   r   r   r	   r
   r   r   r   r   Úlistr#   r0   r5   r9   r?   r6   r>   rG   Ú__all__r   r   r   ú<module>rO      sª  ðà $Ð $Ð $Ð $Ð $Ð $à €€€Ø Ð Ð Ð Ð Ð à RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ Rð)ð )˜# ™) e¤lÑ2ð )¸vð )ð )ð )ð )ð,˜4 œ<ð ð ð ð ðð ˜Vð ¨S°3©Y¸¼Ñ-Eð ÐRVð ð ð ð ð6  (¨6Ô"2ð  °tð  ð  ð  ð  ð�cð ˜dð ð ð ð ð,"˜#ð " $ð "ð "ð "ð "ð$ð ð ð ð$ð ð ð ð*	,�cð 	,ð 	,ð 	,ð 	,ð
ð 
ð 
€€€r   