Ë
    [^(h¦/  ã                   ó>  — d Z ddlZddlZddlZddlZddlmZmZm	Z	 ddl
Z
e
j                  e
j                  e
j                  e
j                  e
j                  e
j                   e
j"                  e
j$                  gZe
j(                  e
j*                  e
j,                  e
j.                  gZe
j2                  e
j4                  e
j6                  e
j8                  gZe
j<                  e
j>                  e
j@                  gZ!e
jD                  ge¢Z#g e¢e!¢Z$de
jJ                  de&de&de
jJ                  fd„Z'ddd	d	d	dd
œde	e(e
jR                  e*e(   e+e(df   f   de
jX                  de	e-e
j\                  f   dee&   dee&   de"de"de"dee
j^                     de
jJ                  fd„Z0y)z1
This module contains tensor creation utilities.
é    N)ÚcastÚOptionalÚUnionÚtÚlowÚhighÚreturnc                 óÒ   — ||z
  t        j                  | j                  «      j                  k\  r'| j	                  |dz  |dz  «      j                  d«      S | j	                  ||«      S )Né   )ÚtorchÚfinfoÚdtypeÚmaxÚuniform_Úmul_)r   r   r   s      úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/testing/_creation.pyÚ_uniform_random_r   $   sX   € ð ˆc�z”U—[‘[ §¡Ó)×-Ñ-Ò-Ø�z‰z˜# ™' 4¨!¡8Ó,×1Ñ1°!Ó4Ð4à�z‰z˜#˜tÓ$Ð$ó    F)r   r   Úrequires_gradÚnoncontiguousÚexclude_zeroÚmemory_formatÚshape.r   Údevicer   r   r   r   c                 ór  ‡ — dt         t           dt         t           dt        dt        dt        dt        dt        t        t        f   fˆ fd„}	t        |«      d	k(  r,t	        |d
   t
        j                  j                  «      r|d
   }t        t        t        df   t        |«      «      }|r|�t        d|›d|›�«      ‚|r‰ t        v rt        d‰ ›�«      ‚|xr t        j                  d„ |d	«      d	kD  }|r't        t        t        df   g |dd ¢d|d   z  ‘­«      }‰ t        j                  u rHt        t        t        t        f    |	||d
dd
d¬«      «      \  }}t        j                   ||||‰ ¬«      }
�nÞ‰ t        v r™t        t        t        t        f    |	||t        j"                  ‰ «      j$                  t        j"                  ‰ «      j&                  ‰ t        j(                  urd	nd
z   dd¬«      «      \  }}t        j                   ||||‰ ¬«      }
�n=‰ t*        v rŽ |	||t        j,                  ‰ «      j$                  t        j,                  ‰ «      j&                  dd¬«      \  }}t        j.                  ||‰ ¬«      }
t1        ‰ t2        v rt        j4                  |
«      n|
||«       n§‰ t6        v r� |	||t        j,                  ‰ «      j$                  t        j,                  ‰ «      j&                  dd¬«      \  }}t        j.                  ||t        j8                  ¬«      }
t1        |
||«       |
j;                  ‰ «      }
nt=        d‰ › d�«      ‚|r|
dd	dd…f   }
n|�|
j?                  |¬«      }
|r/‰ t        v rd	nt        j,                  ‰ «      j@                  |
|
d
k(  <   ‰ t*        v r||
_!        |
S )as  Creates a tensor with the given :attr:`shape`, :attr:`device`, and :attr:`dtype`, and filled with
    values uniformly drawn from ``[low, high)``.

    If :attr:`low` or :attr:`high` are specified and are outside the range of the :attr:`dtype`'s representable
    finite values then they are clamped to the lowest or highest representable finite value, respectively.
    If ``None``, then the following table describes the default values for :attr:`low` and :attr:`high`,
    which depend on :attr:`dtype`.

    +---------------------------+------------+----------+
    | ``dtype``                 | ``low``    | ``high`` |
    +===========================+============+==========+
    | boolean type              | ``0``      | ``2``    |
    +---------------------------+------------+----------+
    | unsigned integral type    | ``0``      | ``10``   |
    +---------------------------+------------+----------+
    | signed integral types     | ``-9``     | ``10``   |
    +---------------------------+------------+----------+
    | floating types            | ``-9``     | ``9``    |
    +---------------------------+------------+----------+
    | complex types             | ``-9``     | ``9``    |
    +---------------------------+------------+----------+

    Args:
        shape (Tuple[int, ...]): Single integer or a sequence of integers defining the shape of the output tensor.
        dtype (:class:`torch.dtype`): The data type of the returned tensor.
        device (Union[str, torch.device]): The device of the returned tensor.
        low (Optional[Number]): Sets the lower limit (inclusive) of the given range. If a number is provided it is
            clamped to the least representable finite value of the given dtype. When ``None`` (default),
            this value is determined based on the :attr:`dtype` (see the table above). Default: ``None``.
        high (Optional[Number]): Sets the upper limit (exclusive) of the given range. If a number is provided it is
            clamped to the greatest representable finite value of the given dtype. When ``None`` (default) this value
            is determined based on the :attr:`dtype` (see the table above). Default: ``None``.

            .. deprecated:: 2.1

                Passing ``low==high`` to :func:`~torch.testing.make_tensor` for floating or complex types is deprecated
                since 2.1 and will be removed in 2.3. Use :func:`torch.full` instead.

        requires_grad (Optional[bool]): If autograd should record operations on the returned tensor. Default: ``False``.
        noncontiguous (Optional[bool]): If `True`, the returned tensor will be noncontiguous. This argument is
            ignored if the constructed tensor has fewer than two elements. Mutually exclusive with ``memory_format``.
        exclude_zero (Optional[bool]): If ``True`` then zeros are replaced with the dtype's small positive value
            depending on the :attr:`dtype`. For bool and integer types zero is replaced with one. For floating
            point types it is replaced with the dtype's smallest positive normal number (the "tiny" value of the
            :attr:`dtype`'s :func:`~torch.finfo` object), and for complex types it is replaced with a complex number
            whose real and imaginary parts are both the smallest positive normal number representable by the complex
            type. Default ``False``.
        memory_format (Optional[torch.memory_format]): The memory format of the returned tensor. Mutually exclusive
            with ``noncontiguous``.

    Raises:
        ValueError: If ``requires_grad=True`` is passed for integral `dtype`
        ValueError: If ``low >= high``.
        ValueError: If either :attr:`low` or :attr:`high` is ``nan``.
        ValueError: If both :attr:`noncontiguous` and :attr:`memory_format` are passed.
        TypeError: If :attr:`dtype` isn't supported by this function.

    Examples:
        >>> # xdoctest: +SKIP
        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_CUDA)
        >>> from torch.testing import make_tensor
        >>> # Creates a float tensor with values in [-1, 1)
        >>> make_tensor((3,), device='cpu', dtype=torch.float32, low=-1, high=1)
        >>> # xdoctest: +SKIP
        tensor([ 0.1205, 0.2282, -0.6380])
        >>> # Creates a bool tensor on CUDA
        >>> make_tensor((2, 2), device='cuda', dtype=torch.bool)
        tensor([[False, False],
                [False, True]], device='cuda:0')
    r   r   Úlowest_inclusiveÚhighest_exclusiveÚdefault_lowÚdefault_highr	   c                óü  •— dt         dt         dt         dt         fd„}| �| n|} |�|n|}t        d„ | |fD «       «      rt        d| ›d|›�«      ‚| |k(  r%‰t        v rt	        j
                  d	t        d
¬«       n;| |k\  rt        d| › d|› �«      ‚||k  s| |k\  rt        d| › d|› d‰› d|› d|› d�«      ‚ || ||«      }  ||||«      }‰t        v r*t        j                  | «      t        j                  |«      fS | |fS )z–
        Modifies (and raises ValueError when appropriate) low and high values given by the user (input_low, input_high)
        if required.
        ÚaÚlÚhr	   c                 ó.   — t        t        | |«      |«      S ©N)Úminr   )r!   r"   r#   s      r   Úclampz3make_tensor.<locals>.modify_low_high.<locals>.clamp�   s   € Ü”s˜1˜a“y !Ó$Ð$r   c              3   ój   K  — | ]+  }t        |t        «      xr t        j                  |«      –— Œ- y ­wr%   )Ú
isinstanceÚfloatÚmathÚisnan)Ú.0Úvalues     r   ú	<genexpr>z7make_tensor.<locals>.modify_low_high.<locals>.<genexpr>“   s(   è ø€ ÒWÀ%Œz˜%¤Ó'Ò=¬D¯J©J°uÓ,=Ó=ÑWùs   ‚13z,`low` and `high` cannot be NaN, but got low=z
 and high=z£Passing `low==high` to `torch.testing.make_tensor` for floating or complex types is deprecated since 2.1 and will be removed in 2.3. Use `torch.full(...)` instead.é   )Ú
stacklevelz(`low` must be less than `high`, but got z >= z5The value interval specified by `low` and `high` is [z, z), but z only supports [ú))
r*   ÚanyÚ
ValueErrorÚ_FLOATING_OR_COMPLEX_TYPESÚwarningsÚwarnÚFutureWarningÚ_BOOLEAN_OR_INTEGRAL_TYPESr+   Úceil)r   r   r   r   r   r   r'   r   s          €r   Úmodify_low_highz$make_tensor.<locals>.modify_low_high   s]  ø€ ð	%”Uð 	%œuð 	%¬ð 	%´5ó 	%ð �_‰c¨+ˆØÐ'‰t¨\ˆäÑWÈCÐQUÈ;ÔWÔWÜØ?¸3¸&ÀÀdÀWÐMóð ð �DŠ[˜UÔ&@Ñ@Ü�M‰Mð1ô Øöð �DŠ[ÜÐGÈÀuÈDÐQUÐPVÐWÓXÐXØÐ$Ò$¨Ð/@Ò(@ÜØGÈÀuÈBÈtÈfð UØ�gÐ-Ð.>Ð-?¸rÐBSÐATÐTUðWóð ñ
 �CÐ)Ð+<Ó=ˆÙ�TÐ+Ð->Ó?ˆàÔ.Ñ.ô —9‘9˜S“>¤4§9¡9¨T£?Ð2Ð2à�DˆyÐr   é   r   .NzaThe parameters `noncontiguous` and `memory_format` are mutually exclusive, but got noncontiguous=z and memory_format=zU`requires_grad=True` is not supported for boolean and integral dtypes, but got dtype=c                 ó   — | |z  S r%   © )ÚxÚys     r   ú<lambda>zmake_tensor.<locals>.<lambda>Á   s
   € ÀAÈÁE€ r   éÿÿÿÿr   )r   r   r   r   )r   r   i÷ÿÿÿé
   é	   zThe requested dtype 'z‚' is not supported by torch.testing.make_tensor(). To request support, file an issue at: https://github.com/pytorch/pytorch/issues)r   )"r   r*   ÚtupleÚlenr)   ÚcollectionsÚabcÚSequencer   Úintr4   r9   Ú	functoolsÚreducer   ÚboolÚrandintÚiinfor&   r   Úint64r5   r   Úemptyr   Ú_COMPLEX_TYPESÚview_as_realÚ_FLOATING_8BIT_TYPESÚfloat32ÚtoÚ	TypeErrorÚcloneÚtinyr   )r   r   r   r   r   r   r   r   r   r;   Úresults   `          r   Úmake_tensorr[   -   sº  ø€ ðd1Ü”e‰_ð1ä”u‰oð1ô  ð	1ô
 !ð1ô ð1ô ð1ô 
Œu”eˆ|Ñ	õ1ôf ˆ5ƒz�Q‚œ: e¨A¡h´·±×0HÑ0HÔIØ�a‘ˆÜ””s˜C�x‘¤%¨£,Ó/€Eá˜Ð2Üð&Ø$Ð&Ð&:¨MÐ+;ð=ó
ð 	
ñ
 ˜Ô"<Ñ<ÜØdÐ^cÐ]eÐfó
ð 	
ð "ÒX¤i×&6Ñ&6Ñ7IÈ5ÐRSÓ&TÐWXÑ&X€MÙô ”Uœ3 ˜8‘_Ð&B¨¨c¨r¨
Ð&B°A¸¸b¹	±MÑ&BÓCˆà”—
‘
ÑÜÜ”#”s�(‰OÙØØØ!"Ø"#ØØôó

‰	ˆˆTô —‘˜s D¨%¸ÀeÔLŠØ	Ô,Ñ	,ÜÜ”#”s�(‰OÙØØÜ!&§¡¨UÓ!3×!7Ñ!7Ü"'§+¡+¨eÓ"4×"8Ñ"8ð ¤U§[¡[Ñ0‘1°añ	#9ð Øôó
‰	ˆˆTô" —‘˜s D¨%¸ÀeÔLŠØ	Ô,Ñ	,Ù#ØØÜ"Ÿ[™[¨Ó/×3Ñ3Ü#Ÿk™k¨%Ó0×4Ñ4ØØô
‰	ˆˆTô —‘˜U¨6¸Ô?ˆÜØ*/´>Ñ*AŒE×Ñ˜vÔ&ÀvÈsÐTXõ	
ð 
Ô&Ñ	&Ù#ØØÜ"Ÿ[™[¨Ó/×3Ñ3Ü#Ÿk™k¨%Ó0×4Ñ4ØØô
‰	ˆˆTô —‘˜U¨6¼¿¹ÔGˆÜ˜  dÔ+Ø—‘˜5Ó!‰äØ# E 7ð +_ð _ó
ð 	
ñ
 à˜˜Q˜T ˜T˜	Ñ"‰Ø	Ð	"Ø—‘¨M�Ó:ˆáàÔ4Ñ4‰A¼%¿+¹+ÀeÓ:L×:QÑ:Qð 	ˆv˜‰{Ñð Ô*Ñ*Ø,ˆÔà€Mr   )1Ú__doc__Úcollections.abcrG   rK   r+   r6   Útypingr   r   r   r   Úuint8Úint8Úint16Úint32rP   Úuint16Úuint32Úuint64Ú_INTEGRAL_TYPESÚfloat16Úbfloat16rU   Úfloat64Ú_FLOATING_TYPESÚfloat8_e4m3fnÚfloat8_e5m2Úfloat8_e4m3fnuzÚfloat8_e5m2fnuzrT   Ú	complex32Ú	complex64Ú
complex128rR   rM   r9   r5   ÚTensorr*   r   rJ   ÚSizeÚlistrE   r   Ústrr   r   r[   r>   r   r   ú<module>rv      sà  ðñó Û Û Û ß (Ñ (ã ð 
‡K�KØ	‡J�JØ	‡K�KØ	‡K�KØ	‡K�KØ	‡L�LØ	‡L�LØ	‡L�Lð	€ð —=‘= %§.¡.°%·-±-ÀÇÁÐO€à	×ÑØ	×ÑØ	×ÑØ	×Ñð	Ð ð —/‘/ 5§?¡?°E×4DÑ4DÐE€Ø#Ÿj™jÐ;¨?Ð;Ð Ø@˜Ð@°Ð@Ð ð%˜Ÿ™ð %¨5ð %¸ð %À%Ç,Á,ó %ð  Ø ØØØØ37ògØ�#�u—z‘z 4¨¡9¨e°C¸°H©oÐ=Ñ>ðgà�;‰;ðgð �#�u—|‘|Ð#Ñ$ðgð 
�%‰ð	gð
 �5‰/ðgð ðgð ðgð ðgð ˜E×/Ñ/Ñ0ðgð ‡\�\ôgr   