§
    Ÿ²Åj=  ã                   ó   — d dl mZmZ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dS )é    )ÚIterableÚListÚ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ÚcudaÚdeviceÚreturnc                 óJ  — t          ¦   «          t          | t          ¦  «        rt          j        | ¦  «        } n*t          | t
          ¦  «        rt          j        d| ¦  «        } | j        }|€t          ¦   «         }t          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.
    r   )r	   Ú
isinstanceÚstrÚtorchr   ÚintÚindexr
   r   Údefault_generatorsÚ	get_state)r   ÚidxÚdefault_generators      úBC:\Projects\Historical\venv\Lib\site-packages\torch/cuda/random.pyr   r      sŒ   € õ �L„L€LÝ�&�#ÑÔð .Ý”˜fÑ%Ô%ˆˆÝ	�F�CÑ	 Ô	 ð .Ý”˜f fÑ-Ô-ˆØ
Œ,€CØ
€{ÝÑÔˆÝœ
Ô5°cÔ:ÐØ×&Ò&Ñ(Ô(Ð(ó    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"   r   r   -   s&   € à?Ð?­­|©~¬~Ñ)>Ô)>Ð?Ñ?Ô?€GØ€Nr#   Ú	new_statec                 óˆ  ‡‡— t           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‰¦  «        Šˆˆ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: ``'cuda'`` (i.e., ``torch.device('cuda')``, the current CUDA device).
    )Úmemory_formatNr   c                  óŽ   •— ‰j         } | €t          ¦   «         } t          j        j        |          }|                     ‰¦  «         d S ©N)r   r
   r   r   r   Ú	set_state)r    r!   r   Únew_state_copys     €€r"   Úcbzset_rng_state.<locals>.cbD   sD   ø€ ØŒlˆØˆ;Ý Ñ"Ô"ˆCÝ!œJÔ9¸#Ô>ÐØ×#Ò# NÑ3Ô3Ð3Ð3Ð3r#   )
r   Ú_CÚ_DisableFuncTorchÚcloneÚcontiguous_formatr   r   r   r   r   )r,   r   r3   r2   s    ` @r"   r   r   3   s  øø€ õ 
Œ×	#Ò	#Ñ	%Ô	%ð Pð PØ"ŸšµuÔ7N˜ÑOÔOˆðPð Pð Pñ Pô Pð Pð Pð Pð Pð Pð Pøøøð Pð Pð Pð På�&�#ÑÔð .Ý”˜fÑ%Ô%ˆˆÝ	�F�CÑ	 Ô	 ð .Ý”˜f fÑ-Ô-ˆð4ð 4ð 4ð 4ð 4ð 4õ ˆ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)Ú	enumerater   )r8   r(   Ústates      r"   r   r   N   s<   € õ ˜jÑ)Ô)ð  ð  ‰ˆˆ5Ý�e˜QÑÔÐÐð ð  r#   r   c                 óR   ‡ — t          ‰ ¦  «        Š ˆ 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 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                  ó|   •— t          ¦   «         } t          j        j        |          }|                     ‰¦  «         d S r0   )r
   r   r   r   r   )r    r!   r   s     €r"   r3   zmanual_seed.<locals>.cbg   s8   ø€ ÝÑÔˆÝ!œJÔ9¸#Ô>ÐØ×%Ò% dÑ+Ô+Ð+Ð+Ð+r#   T)r   N©r   r   ©r   r3   s   ` r"   r   r   X   sD   ø€ õ ˆt‰9Œ9€Dð,ð ,ð ,ð ,ð ,õ
 ˆr˜ÐÑÔÐÐÐr#   c                 óR   ‡ — t          ‰ ¦  «        Š ˆ 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 CUDA is not available; in that
    case, it is silently ignored.

    Args:
        seed (int): The desired seed.
    c                  óœ   •— t          t          ¦   «         ¦  «        D ].} t          j        j        |          }|                     ‰¦  «         Œ/d S r0   )r*   r   r   r   r   r   )r(   r!   r   s     €r"   r3   zmanual_seed_all.<locals>.cbz   sO   ø€ Ý•|‘~”~Ñ&Ô&ð 	0ð 	0ˆAÝ %¤
Ô =¸aÔ @ÐØ×)Ò)¨$Ñ/Ô/Ð/Ð/ð	0ð 	0r#   T)r   Nr>   r?   s   ` r"   r   r   o   sD   ø€ õ ˆt‰9Œ9€Dð0ð 0ð 0ð 0ð 0õ
 ˆr˜DÐ!Ñ!Ô!Ð!Ð!Ð!r#   c                  ó*   — d„ } t          | ¦  «         dS )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                  óx   — t          ¦   «         } t          j        j        |          }|                     ¦   «          d S r0   )r
   r   r   r   r   ©r    r!   s     r"   r3   zseed.<locals>.cb�   s5   € ÝÑÔˆÝ!œJÔ9¸#Ô>ÐØ×ÒÑ Ô Ð Ð Ð r#   N©r   ©r3   s    r"   r   r   ‚   s"   € ð!ð !ð !õ
 ˆr�N„N€N€N€Nr#   c                  ó*   — 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 CUDA is not available; in that
    case, it is silently ignored.
    c                  óü   — d} d}t          t          ¦   «         ¦  «        D ][}t          j        j        |         }|s+|                     ¦   «          |                     ¦   «         } d}ŒF|                     | ¦  «         Œ\d S )Nr   FT)r*   r   r   r   r   r   r   r   )Úrandom_seedÚseededr(   r!   s       r"   r3   zseed_all.<locals>.cbœ   sŠ   € ØˆØˆÝ•|‘~”~Ñ&Ô&ð 	;ð 	;ˆAÝ %¤
Ô =¸aÔ @ÐØð ;Ø!×&Ò&Ñ(Ô(Ð(Ø/×<Ò<Ñ>Ô>�Ø��à!×-Ò-¨kÑ:Ô:Ð:Ð:ð	;ð 	;r#   NrE   rF   s    r"   r   r   •   s"   € ð
;ð 
;ð 
;õ ˆr�N„N€N€N€Nr#   c                  ó�   — t          ¦   «          t          ¦   «         } t          j        j        |          }|                     ¦   «         S )zyReturn the current random seed of the current GPU.

    .. warning::
        This function eagerly initializes CUDA.
    )r	   r
   r   r   r   r   rD   s     r"   r   r   «   s:   € õ �L„L€LÝ
Ñ
Ô
€CÝœ
Ô5°cÔ:ÐØ×)Ò)Ñ+Ô+Ð+r#   )r   )r   N)Útypingr   r   r   r   r   Ú r   r	   r
   r   Ú__all__r   r   r   r   r   r   r   r   r   r   r   r   r&   r#   r"   ú<module>rO      sÅ  ðà (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ð (à €€€Ø Ð Ð Ð Ð Ð à BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ Bð
ð 
ð 
€ð)ð )˜%  S¨%¬,Ð 6Ô7ð )ÀVð )ð )ð )ð )ð,˜4 œ<ð ð ð ð ð @Fðð ØðØ$ S¨#¨u¬|Ð%;Ô<ðà	ðð ð ð ð6  (¨6Ô"2ð  °tð  ð  ð  ð  ð�cð ˜dð ð ð ð ð."˜#ð " $ð "ð "ð "ð "ð&ð ð ð ð&ð ð ð ð,	,�cð 	,ð 	,ð 	,ð 	,ð 	,ð 	,r#   