
    3Ki                     *   S SK Jr  S SKrS SKJr  SSKJrJrJrJrJ	r	  SS\
\-  \R                  -  S\4S jjrS\\   4S	 jrSS
\S\
\-  \R                  -  SS4S jjrS\\   SS4S jrS\
SS4S jrS\
SS4S jrSS jrSS jrS\
4S jr/ SQrg)    )IterableN)Tensor   )
_lazy_call
_lazy_initcurrent_devicedevice_countis_initializeddevicereturnc                 R   [        5         [        U [        5      (       a  [        R                  " U 5      n O,[        U [
        5      (       a  [        R                  " SU 5      n U R                  nUc
  [        5       n[        R                  R                  U   nUR                  5       $ )a6  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/html/dynamic-report/venv/lib/python3.13/site-packages/torch/xpu/random.pyget_rng_stater   
   s{     L&#f%	FC	 	 eV,
,,C
{		44S9&&((    c                  h    [        [        5       5       V s/ s H  n [        U 5      PM     nn U$ s  sn f )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                   ^ ^ [        5       (       dD  [        R                  R                  5          T R	                  [        R
                  S9m SSS5        [        T[        5      (       a  [        R                  " T5      mO,[        T[        5      (       a  [        R                  " ST5      mSUU 4S jjn[        U5        g! , (       d  f       N{= f)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                     > TR                   n U c
  [        5       n [        R                  R                  U    nUR                  T5        g N)r   r   r   r   r   	set_state)r   r   r   r    s     r   cbset_rng_state.<locals>.cb7   s<    ll; "C!II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     XX'')!e6M6MNI * &#f%	FC	 	 eV,/ / rN *)s   C
C
new_statesc                 B    [        U 5       H  u  p[        X!5        M     g)zSet 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_allr2   A   s     j)e *r   seedc                 @   ^  [        T 5      m SU 4S jjn[        USS9  g)al  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   > [        5       n [        R                  R                  U    nUR	                  T5        g r$   )r   r   r   r   manual_seed)r   r   r3   s     r   r&   manual_seed.<locals>.cbY   s.    !II88=%%d+r   T)r3   r(   r   r   r3   r&   s   ` r   r6   r6   K   s     t9D,
 rr   c                 @   ^  [        T 5      m SU 4S jjn[        USS9  g)zSet 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                     > [        [        5       5       H1  n [        R                  R                  U    nUR                  T5        M3     g r$   )r   r	   r   r   r   r6   )r   r   r3   s     r   r&   manual_seed_all.<locals>.cbk   s7    |~&A %		 < <Q ?))$/ 'r   T)seed_allr(   r8   r9   s   ` r   manual_seed_allr>   a   s     t9D0
 rD!r   c                  $    SS jn [        U 5        g)a[  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    [        5       n [        R                  R                  U    nUR	                  5         g r$   )r   r   r   r   r3   r   r   s     r   r&   seed.<locals>.cb}   s+    !II88= r   r(   r   r&   s    r   r3   r3   s   s    !
 rNr   c                  $    SS jn [        U 5        g)zSet 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                      Sn Sn[        [        5       5       H\  n[        R                  R                  U   nU(       d$  UR                  5         UR                  5       n SnMK  UR                  U 5        M^     g )Nr   FT)r   r	   r   r   r   r3   initial_seedr6   )random_seedseededr   r   s       r   r&   seed_all.<locals>.cb   sb    |~&A %		 < <Q ?!&&(/<<>!--k: 'r   r(   rC   rD   s    r   r=   r=      s    
; rNr   c                      [        5         [        5       n [        R                  R                  U    nUR                  5       $ )zlReturn the current random seed of the current GPU.

.. warning::
    This function eagerly initializes XPU.
)r   r   r   r   r   rG   rA   s     r   rG   rG      s5     L

C		44S9))++r   )	r   r   r-   r2   r6   r>   r3   r=   rG   )r   r(   )collections.abcr   r   r    r   r   r   r	   r
   r   r   r   r   listr   r-   r2   r6   r>   r3   r=   rG   __all__ r   r   <module>rQ      s    $   R R)#)ell2 )v ),4< V S3Y-E RV 6 (6"2  t  c d ,"# "$ "$$*	,c 	,
r   