
    [Th,                        S SK r S SKrS SKJr  S SKrS SKJr  S\R                  SS4S jrS\R                  4S jr	S\R                  R                  4S jrS\4S	 jrSS
 jrS\4S jrSq\ R"                       SS\4S jj5       rg)    N)	Generator)default_generator	new_statereturnc                 0    [         R                  " U 5        g)zSets the random number generator state.

.. note:: This function only works for CPU. For CUDA, please use
    :func:`torch.manual_seed`, which works for both CPU and CUDA.

Args:
    new_state (torch.ByteTensor): The desired state
N)r   	set_state)r   s    D/var/www/auris/envauris/lib/python3.13/site-packages/torch/random.pyset_rng_stater
   
   s     	*    c                  ,    [         R                  " 5       $ )zReturns the random number generator state as a `torch.ByteTensor`.

.. note:: The returned state is for the default generator on CPU only.

See also: :func:`torch.random.fork_rng`.
)r   	get_state r   r	   get_rng_stater      s     &&((r   c                    [        U 5      n SSKnUR                  R                  5       (       d  UR                  R	                  U 5        SSKnUR                  R                  5       (       d  UR                  R                  U 5        SSKnUR                  R                  5       (       d  UR                  R	                  U 5        [        U 5        [        R                  " U 5      $ )a  Sets the seed for generating random numbers on all devices. Returns a
`torch.Generator` object.

Args:
    seed (int): The desired seed. Value must be within the inclusive range
        `[-0x8000_0000_0000_0000, 0xffff_ffff_ffff_ffff]`. Otherwise, a RuntimeError
        is raised. Negative inputs are remapped to positive values with the formula
        `0xffff_ffff_ffff_ffff + seed`.
r   N)int
torch.cudacuda_is_in_bad_forkmanual_seed_all	torch.mpsmpsmanual_seed	torch.xpuxpu_seed_custom_devicer   seedtorchs     r	   r   r       s     t9D::%%''

""4(99$$&&		d#99$$&&		!!$'((..r   c                     [         R                  " 5       n SSKnUR                  R	                  5       (       d  UR                  R                  U 5        SSKnUR                  R	                  5       (       d  UR                  R                  U 5        SSK	nUR                  R	                  5       (       d  UR                  R                  U 5        [        U 5        U $ )zSets the seed for generating random numbers to a non-deterministic
random number on all devices. Returns a 64 bit number used to seed the RNG.
r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   s     r	   r   r   ?   s     !!#D::%%''

""4(99$$&&		d#99$$&&		!!$'Kr   c                    [        U 5      n [        R                  R                  5       n[	        [        U5      (       a  [        [        U5      nSnSn[	        X#5      (       a8  [	        X$5      (       a(  [        X#5      " 5       (       d  [        X$5      " U 5        ggSU S3nUSU SU SU S3-  n[        R                  " U[        S	S
9  gg)zSets the seed to generate random numbers for custom device.

Args:
    seed (int): The desired seed.

See [Note: support the custom device with privateuse1]
r   r   zSet seed for `z0` device does not take effect, please add API's `z` and `z` to `z` device module.   )
stacklevelN)	r   r   _C_get_privateuse1_backend_namehasattrgetattrwarningswarnUserWarning)r   custom_backend_namecustom_device_mod_bad_fork_name_seed_all_namemessages         r	   r   r   X   s     t9D((@@Bu)**#E+>?**$55';
 ;
 ,=??):4@ @ '':&;;klG>*'.1AH[G\\lmmGMM';1= +r   c                  ,    [         R                  " 5       $ )zReturns the initial seed for generating random numbers as a
Python `long`.

.. note:: The returned seed is for the default generator on CPU only.
)r   initial_seedr   r   r	   r1   r1   q   s     ))++r   Fc              #     #    US:X  a  Sv   g[         R                  " U5      R                  n[        [         US5      nUc  [	        SU S3S-   5      eU(       d  Sv   gU c  UR                  5       nUS:  a  [        (       d  UR                  5        SU SU S	UR                  5        S
UR                  5        SUR                  5        SUR                  5        SU SU SUR                  5        SU SU S3n[        R                  " U5        Sq[        [        U5      5      n O[        U 5      n [         R                  " 5       nU  V	s/ s H  oR                  U	5      PM     n
n	 Sv   [         R                  " U5        [        X
5       H  u  pUR                  X5        M     gs  sn	f ! [         R                  " U5        [        X
5       H  u  pUR                  X5        M     f = f7f)aQ  
Forks the RNG, so that when you return, the RNG is reset
to the state that it was previously in.

Args:
    devices (iterable of Device IDs): devices for which to fork
        the RNG. CPU RNG state is always forked. By default, :meth:`fork_rng` operates
        on all devices, but will emit a warning if your machine has a lot
        of devices, since this function will run very slowly in that case.
        If you explicitly specify devices, this warning will be suppressed
    enabled (bool): if ``False``, the RNG is not forked.  This is a convenience
        argument for easily disabling the context manager without having
        to delete it and unindent your Python code under it.
    device_type (str): device type str, default is `cuda`. As for custom device,
        see details in [Note: support the custom device with privateuse1]
metaNztorch has no module of `z`, you should register z,a module by `torch._register_device_module`.   z reports that you have z& available devices, and you have used z_ without explicitly specifying which devices are being used. For safety, we initialize *every* zA device by default, which can be quite slow if you have a lot of z5s. If you know that you are only making use of a few z' devices, set the environment variable z_VISIBLE_DEVICES or the 'z' keyword argument of z with the set of devices you are actually using. For example, if you are using CPU only, set device.upper()_VISIBLE_DEVICES= or devices=[]; if you are using device 0 only, set zb_VISIBLE_DEVICES=0 or devices=[0].  To initialize all devices and suppress this warning, set the 'z#' keyword argument to `range(torch.z.device_count())`.T)r   devicetyper'   RuntimeErrordevice_count_fork_rng_warned_alreadyupperr(   r)   listranger   r
   zip)devicesenabled_caller_devices_kwdevice_type
device_modnum_devicesr/   cpu_rng_stater5   device_rng_statesdevice_rng_states               r	   fork_rngrH   }   s    2 f,,{+00KT2J&{m3JK<=
 	
  --/?#;#;$$&''>{m L!!(	 *55@5F5F5H4I J66A6G6G6I5J K((3(9(9(;'<<c$$&''@Mcdkcl m #((*+ ,77Bm D  +},>
@  MM'"'+$u[)* w-'')MHOPf11&9P?M*(+G(G$F$$%5> )H Q
 	M*(+G(G$F$$%5> )Hs+   EG1F,)G1,F1 0AG11=G..G1)r   N)NTrH   r>   r   )
contextlibr(   collections.abcr   r   torch._Cr   Tensorr
   r   r$   r   r   r   r   r1   r9   contextmanagerrH   r   r   r	   <module>rN      s      %  &	+U\\ 	+d 	+)u|| )/++ />c 2>2,c , !  M? M? M?r   