Ë
    Z^(hw  ã                   ó  — 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m	Z	m
Z
 ddeeeej                  f   defd	„Zdee   fd
„Z	 ddedeeeej                  f   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)é    )ÚIterable)ÚUnionN)ÚTensoré   )Ú
_lazy_callÚ
_lazy_initÚcurrent_deviceÚdevice_countÚ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      úN/var/www/skyplay_api_hub/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                 óh  ‡‡— t         j                  j                  «       5  | j                  t         j                  ¬«      Šddd«       t        ‰t        «      rt        j                  ‰«      Šn&t        ‰t        «      rt        j                  d‰«      Šˆˆfd„}t        |«       y# 1 sw Y   Œgx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   Únew_state_copys     €€r   Úcbzset_rng_state.<locals>.cb8   s<   ø€ Ø�l‰lˆØˆ;Ü Ó"ˆCÜ!ŸI™I×8Ñ8¸Ñ=ÐØ×#Ñ# NÕ3r   )
r   Ú_CÚ_DisableFuncTorchÚcloneÚcontiguous_formatr   r   r   r   r   )r    r   r'   r&   s    ` @r   Úset_rng_stater,   '   s„   ù€ ô 
�‰×	#Ñ	#Ó	%ñ PØ"Ÿ™´u×7NÑ7N˜ÓOˆ÷Pä�&œ#ÔÜ—‘˜fÓ%‰Ü	�FœCÔ	 Ü—‘˜e VÓ,ˆõ4ô ˆr…N÷Pð Pús   ¡!B(Â(B1Ú
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   B   s&   € ô ˜jÓ)ò  ‰ˆˆ5Ü�e˜QÕñ r   Úseedc                 ó@   ‡ — t        ‰ «      Š ˆ 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`.
    c                  óv   •— t        «       } t        j                  j                  |    }|j	                  ‰«       y r$   )r	   r   r   r   Úmanual_seed)r   r   r2   s     €r   r'   zmanual_seed.<locals>.cbZ   s.   ø€ ÜÓˆÜ!ŸI™I×8Ñ8¸Ñ=ÐØ×%Ñ% dÕ+r   T)r2   N©r   r   ©r2   r'   s   ` r   r5   r5   L   s   ø€ ô ˆt‹9€Dô,ô
 ˆr˜Ör   c                 ó@   ‡ — t        ‰ «      Š ˆ 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.
    c                  ó’   •— 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>.cbl   s<   ø€ Ü”|“~Ó&ò 	0ˆAÜ %§	¡	× <Ñ <¸QÑ ?ÐØ×)Ñ)¨$Õ/ñ	0r   T)Úseed_allNr6   r7   s   ` r   Úmanual_seed_allr;   b   s   ø€ ô ˆt‹9€Dô0ô
 ˆr˜DÖ!r   c                  ó    — 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`.
    c                  ó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   N©r   ©r'   s    r   r2   r2   t   s   € ò!ô
 ˆr…Nr   c                  ó    — 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.
    c                  óâ   — 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   Nr?   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   N)Úcollections.abcr   Útypingr   r   r   Ú r   r   r	   r
   r   r   r   r   Úlistr   r,   r1   r5   r;   r2   r:   rC   Ú__all__© r   r   ú<module>rM      sÙ   ðå $Ý ã Ý ç BÓ Bñ)˜%  S¨%¯,©,Ð 6Ñ7ð )ÀFó )ð,˜4 ™<ó ð @EñØðØ$ S¨#¨u¯|©|Ð%;Ñ<ðà	óð6  (¨6Ñ"2ð  °tó  ð�cð ˜dó ð,"˜#ð " $ó "ó$ó$ð*	,�có 	,ò
�r   