Ë
    g^(hž  ã                   ó  — 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
 g d¢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y)é    )ÚIterable)ÚUnionN)ÚTensoré   )Ú
_lazy_callÚ
_lazy_initÚcurrent_deviceÚdevice_count)	Úget_rng_stateÚget_rng_state_allÚset_rng_stateÚset_rng_state_allÚmanual_seedÚmanual_seed_allÚseedÚseed_allÚinitial_seedÚdeviceÚreturnc                 ó8  — t        «        t        | t        «      rt        j                  | «      } n&t        | t
        «      rt        j                  d| «      } | j                  }|€
t        «       }t        j                  j                  |   }|j                  «       S )aR  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: ``'cuda'`` (i.e., ``torch.device('cuda')``, the current CUDA device).

    .. warning::
        This function eagerly initializes CUDA.
    Úcuda)r   Ú
isinstanceÚstrÚtorchr   ÚintÚindexr	   r   Údefault_generatorsÚ	get_state)r   ÚidxÚdefault_generators      úO/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/cuda/random.pyr   r      su   € ô „LÜ�&œ#ÔÜ—‘˜fÓ%‰Ü	�FœCÔ	 Ü—‘˜f fÓ-ˆØ
�,‰,€CØ
€{ÜÓˆÜŸ
™
×5Ñ5°cÑ:ÐØ×&Ñ&Ó(Ð(ó    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!   r   r   .   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: ``'cuda'`` (i.e., ``torch.device('cuda')``, the current CUDA 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>.cbE   s<   ø€ Ø�l‰lˆØˆ;Ü Ó"ˆCÜ!ŸJ™J×9Ñ9¸#Ñ>ÐØ×#Ñ# NÕ3r"   )
r   Ú_CÚ_DisableFuncTorchÚcloneÚcontiguous_formatr   r   r   r   r   )r'   r   r.   r-   s    ` @r!   r   r   4   s„   ù€ ô 
�‰×	#Ñ	#Ó	%ñ PØ"Ÿ™´u×7NÑ7N˜ÓOˆ÷Pä�&œ#ÔÜ—‘˜fÓ%‰Ü	�FœCÔ	 Ü—‘˜f fÓ-ˆõ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   )r3   r%   Ústates      r!   r   r   O   s&   € ô ˜jÓ)ò  ‰ˆˆ5Ü�e˜QÕñ r"   r   c                 ó@   ‡ — 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 CUDA 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   r   )r   r    r   s     €r!   r.   zmanual_seed.<locals>.cbh   s.   ø€ ÜÓˆÜ!ŸJ™J×9Ñ9¸#Ñ>ÐØ×%Ñ% dÕ+r"   T)r   N©r   r   ©r   r.   s   ` r!   r   r   Y   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 CUDA 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   r   )r%   r    r   s     €r!   r.   zmanual_seed_all.<locals>.cb{   s<   ø€ Ü”|“~Ó&ò 	0ˆAÜ %§
¡
× =Ñ =¸aÑ @ÐØ×)Ñ)¨$Õ/ñ	0r"   T)r   Nr9   r:   s   ` r!   r   r   p   s   ø€ ô ˆt‹9€Dô0ô
 ˆr˜DÖ!r"   c                  ó    — d„ } t        | «       y)at  Set the seed for generating random numbers to a random number for the current GPU.

    It's safe to call this function if CUDA 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   r   ©r   r    s     r!   r.   zseed.<locals>.cbŽ   s+   € ÜÓˆÜ!ŸJ™J×9Ñ9¸#Ñ>ÐØ×ÑÕ r"   N©r   ©r.   s    r!   r   r   ƒ   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 CUDA 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   r   r   r   )Úrandom_seedÚseededr%   r    s       r!   r.   zseed_all.<locals>.cb�   sg   € ØˆØˆÜ”|“~Ó&ò 	;ˆAÜ %§
¡
× =Ñ =¸aÑ @ÐÙØ!×&Ñ&Ô(Ø/×<Ñ<Ó>�Ø‘à!×-Ñ-¨kÕ:ñ	;r"   Nr@   rA   s    r!   r   r   –   s   € ò
;ô ˆr…Nr"   c                  ó„   — t        «        t        «       } t        j                  j                  |    }|j                  «       S )zyReturn the current random seed of the current GPU.

    .. warning::
        This function eagerly initializes CUDA.
    )r   r	   r   r   r   r   r?   s     r!   r   r   ¬   s5   € ô „LÜ
Ó
€CÜŸ
™
×5Ñ5°cÑ:ÐØ×)Ñ)Ó+Ð+r"   )r   )r   N)Úcollections.abcr   Útypingr   r   r   Ú r   r   r	   r
   Ú__all__r   r   r   r   Úlistr   r   r   r   r   r   r   r   © r"   r!   ú<module>rM      sÙ   ðå $Ý ã Ý ç BÓ Bò
€ñ)˜%  S¨%¯,©,Ð 6Ñ7ð )ÀVó )ð,˜4 ™<ó ð @FñØðØ$ S¨#¨u¯|©|Ð%;Ñ<ðà	óð6  (¨6Ñ"2ð  °tó  ð�cð ˜dó ð."˜#ð " $ó "ó&ó&ð,	,�cô 	,r"   