Ë
    3êñi¢  ã                   ó  — 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y)é    )ÚIterableN)ÚTensoré   )Ú
_lazy_callÚ
_lazy_initÚcurrent_deviceÚdevice_countÚis_initializedÚdeviceÚreturnc                 ó8  — t        «        t        | t        «      rt        j                  | «      } n&t        | t
        «      rt        j                  d| «      } | j                  }|€
t        «       }t        j                  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.
    Úxpu)r   Ú
isinstanceÚstrÚtorchr   ÚintÚindexr   r   Údefault_generatorsÚ	get_state)r   ÚidxÚdefault_generators      úR/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/torch/xpu/random.pyÚget_rng_stater   
   su   € ô „LÜ�&œ#ÔÜ—‘˜fÓ%‰Ü	�FœCÔ	 Ü—‘˜e VÓ,ˆØ
�,‰,€CØ
€{ÜÓˆÜŸ	™	×4Ñ4°SÑ9ÐØ×&Ñ&Ó(Ð(ó    c                  ób   — t        t        «       «      D � cg c]  } t        | «      ‘Œ }} |S c c} w )zQReturn a list of ByteTensor representing the random number states of all devices.)Úranger	   r   )ÚiÚresultss     r   Úget_rng_state_allr       s,   € ä).¬|«~Ó)>Ö? AŒ}˜QÕÐ?€GÐ?Ø€Nùò @s   –,Ú	new_statec                 ó~  ‡ ‡— t        «       sGt        j                  j                  «       5  ‰ j	                  t        j
                  ¬«      Š ddd«       t        ‰t        «      rt        j                  ‰«      Šn&t        ‰t        «      rt        j                  d‰«      Šdˆˆ fd„}t        |«       y# 1 sw Y   ŒhxY w)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   c                  ó’   •— ‰j                   } | €
t        «       } t        j                  j                  |    }|j                  ‰«       y ©N)r   r   r   r   r   Ú	set_state)r   r   r   r    s     €€r   Úcbzset_rng_state.<locals>.cb7   s<   ø€ Ø�l‰lˆØˆ;Ü Ó"ˆCÜ!ŸI™I×8Ñ8¸Ñ=ÐØ×#Ñ# IÕ.r   ©r   N)r
   r   Ú_CÚ_DisableFuncTorchÚcloneÚcontiguous_formatr   r   r   r   r   )r    r   r&   s   `` r   Úset_rng_stater,   &   sŒ   ù€ ô ÔÜ�X‰X×'Ñ'Ó)ñ 	OØ!Ÿ™´e×6MÑ6M˜ÓNˆI÷	Oô �&œ#ÔÜ—‘˜fÓ%‰Ü	�FœCÔ	 Ü—‘˜e VÓ,ˆö/ô ˆr…N÷	Oð 	Oús   «!B3Â3B<Ú
new_statesc                 óB   — t        | «      D ]  \  }}t        ||«       Œ y)z›Set 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_allr1   A   s&   € ô ˜jÓ)ò  ‰ˆˆ5Ü�e˜QÕñ r   Úseedc                 óB   ‡ — t        ‰ «      Š dˆ fd„}t        |d¬«       y)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`.
    Nc                  óv   •— t        «       } t        j                  j                  |    }|j	                  ‰«       y r$   )r   r   r   r   Úmanual_seed)r   r   r2   s     €r   r&   zmanual_seed.<locals>.cbY   s.   ø€ ÜÓˆÜ!ŸI™I×8Ñ8¸Ñ=ÐØ×%Ñ% dÕ+r   T)r2   r'   ©r   r   ©r2   r&   s   ` r   r5   r5   K   s   ø€ ô ˆt‹9€Dõ,ô
 ˆr˜Ör   c                 óB   ‡ — t        ‰ «      Š dˆ fd„}t        |d¬«       y)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.
    Nc                  ó’   •— t        t        «       «      D ]0  } t        j                  j                  |    }|j                  ‰«       Œ2 y r$   )r   r	   r   r   r   r5   )r   r   r2   s     €r   r&   zmanual_seed_all.<locals>.cbk   s<   ø€ Ü”|“~Ó&ò 	0ˆAÜ %§	¡	× <Ñ <¸QÑ ?ÐØ×)Ñ)¨$Õ/ñ	0r   T)Úseed_allr'   r6   r7   s   ` r   Úmanual_seed_allr;   a   s   ø€ ô ˆt‹9€Dõ0ô
 ˆr˜DÖ!r   c                  ó"   — dd„} t        | «       y)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`.
    Nc                  ór   — t        «       } t        j                  j                  |    }|j	                  «        y r$   )r   r   r   r   r2   ©r   r   s     r   r&   zseed.<locals>.cb}   s+   € ÜÓˆÜ!ŸI™I×8Ñ8¸Ñ=ÐØ×ÑÕ r   r'   ©r   ©r&   s    r   r2   r2   s   s   € ó!ô
 ˆr…Nr   c                  ó"   — dd„} t        | «       y)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.
    Nc                  óâ   — d} d}t        t        «       «      D ]U  }t        j                  j                  |   }|s#|j                  «        |j                  «       } d}ŒE|j                  | «       ŒW y )Nr   FT)r   r	   r   r   r   r2   Úinitial_seedr5   )Úrandom_seedÚseededr   r   s       r   r&   zseed_all.<locals>.cb‹   sg   € ØˆØˆÜ”|“~Ó&ò 	;ˆAÜ %§	¡	× <Ñ <¸QÑ ?ÐÙØ!×&Ñ&Ô(Ø/×<Ñ<Ó>�Ø‘à!×-Ñ-¨kÕ:ñ	;r   r'   r?   r@   s    r   r:   r:   …   s   € ó
;ô ˆr…Nr   c                  ó„   — t        «        t        «       } t        j                  j                  |    }|j                  «       S )zxReturn the current random seed of the current GPU.

    .. warning::
        This function eagerly initializes XPU.
    )r   r   r   r   r   rC   r>   s     r   rC   rC   š   s5   € ô „LÜ
Ó
€CÜŸ	™	×4Ñ4°SÑ9ÐØ×)Ñ)Ó+Ð+r   )	r   r   r,   r1   r5   r;   r2   r:   rC   )r   r'   )Úcollections.abcr   r   r   Ú r   r   r   r	   r
   r   r   r   r   Úlistr   r,   r1   r5   r;   r2   r:   rC   Ú__all__© r   r   ú<module>rL      sÇ   ðå $ã Ý ç RÕ Rñ)˜# ™) e§l¡lÑ2ð )¸vó )ð,˜4 ™<ó ñ˜Vð ¨S°3©Y¸¿¹Ñ-Eð ÐRVó ð6  (¨6Ñ"2ð  °tó  ð�cð ˜dó ð,"˜#ð " $ó "ó$ó$ð*	,�có 	,ò
�r   