
    JTh/                     D   S r SSKrSSKrSSKrSSKrSSKJrJrJ	r	  SSK
r
\
R                  \
R                  \
R                  \
R                  \
R                  \
R                   \
R"                  \
R$                  /r\
R(                  \
R*                  \
R,                  \
R.                  /r\
R2                  \
R4                  \
R6                  \
R8                  /r\
R<                  \
R>                  \
R@                  /r!\
RD                  /\Qr#/ \Q\!Qr$S\
RJ                  S\&S\&S\
RJ                  4S jr'SSS	S	S	SS
.S\	\(\
RR                  \*\(   \+\(S4   4   S\
RX                  S\	\-\
R\                  4   S\\&   S\\&   S\"S\"S\"S\\
R^                     S\
RJ                  4S jjr0g)z1
This module contains tensor creation utilities.
    N)castOptionalUniontlowhighreturnc                     X!-
  [         R                  " U R                  5      R                  :  a'  U R	                  US-  US-  5      R                  S5      $ U R	                  X5      $ )N   )torchfinfodtypemaxuniform_mul_)r   r   r   s      O/var/www/auris/envauris/lib/python3.13/site-packages/torch/testing/_creation.py_uniform_random_r   $   sT     zU[[)---zz#'4!8,11!44zz#$$    F)r   r   requires_gradnoncontiguousexclude_zeromemory_formatshape.r   devicer   r   r   r   c                   ^  S[         [           S[         [           S[        S[        S[        S[        S[        [        [        4   4U 4S jjn	[        U5      S	:X  a1  [	        US
   [
        R                  R                  5      (       a  US
   n[        [        [        S4   [        U5      5      nU(       a  Ub  [        SU< SU< 35      eU(       a  T [        ;   a  [        ST < 35      eU=(       a    [        R                  " S US	5      S	:  nU(       a'  [        [        [        S4   / USS QSUS   -  P75      nT [        R                  L a@  [        [        [        [        4   U	" UUS
SS
SS95      u  p#[        R                   " X#XT S9n
GOT [        ;   a  [        [        [        [        4   U	" UU[        R"                  " T 5      R$                  [        R"                  " T 5      R&                  T [        R(                  La  S	OS
-   SSS95      u  p#[        R                   " X#XT S9n
GO8T [*        ;   a  U	" UU[        R,                  " T 5      R$                  [        R,                  " T 5      R&                  SSS9u  p#[        R.                  " XT S9n
[1        T [2        ;   a  [        R4                  " U
5      OU
X#5        OT [6        ;   a  U	" UU[        R,                  " T 5      R$                  [        R,                  " T 5      R&                  SSS9u  p#[        R.                  " X[        R8                  S9n
[1        XU5        U
R;                  T 5      n
O[=        ST  S35      eU(       a  U
SS	SS24   n
OUb  U
R?                  US9n
U(       a1  T [        ;   a  S	O[        R,                  " T 5      R@                  XS
:H  '   T [*        ;   a  XJl!        U
$ )a  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                  > S[         S[         S[         S[         4S jnU b  U OUn Ub  UOUn[        S X4 5       5      (       a  [        SU < SU< 35      eX:X  a%  T[        ;   a  [        R
                  " S	[        S
S9  O;X:  a  [        SU  SU 35      eX:  d  X:  a  [        SU  SU ST SU SU S35      eU" XU5      n U" XU5      nT[        ;   a,  [        R                  " U 5      [        R                  " U5      4$ X4$ )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                 ,    [        [        X5      U5      $ N)minr   )r!   r"   r#   s      r   clamp3make_tensor.<locals>.modify_low_high.<locals>.clamp   s    s1y!$$r   c              3   |   #    U  H2  n[        U[        5      =(       a    [        R                  " U5      v   M4     g 7fr%   )
isinstancefloatmathisnan).0values     r   	<genexpr>7make_tensor.<locals>.modify_low_high.<locals>.<genexpr>   s(     W;%z%'=DJJu,==;s   :<z,`low` and `high` cannot be NaN, but got low=z
 and high=zPassing `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_high$make_tensor.<locals>.modify_low_high   sK   	%U 	%u 	% 	%5 	% _c+'t\WC;WWW?3&dWM  [U&@@MM1  [GuDQUPVWXX$(@GuBtf Ug-.>-?rBSATTUW 
 C+<=T->?.. 99S>499T?22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                 
    X-  $ r%    )xys     r   <lambda>make_tensor.<locals>.<lambda>   s    AEr   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   intr6   r;   	functoolsreducer   boolrandintiinfor&   r   int64r7   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uo1  	1
 !1 1 1 
ue|	1f 5zQ:eAh0H0HIIasCx%,/E2&$&&:M+;=
 	

 "<<d^c]ef
 	
 "Xi&6&67I5RS&TWX&XM U38_&Bcr
&BAb	M&BC

#s(O!""#

	 s%eL	,	,#s(O!&U!3!7!7"'++e"4"8"8 U[[01a	#9 
	" s%eL	,	,#"[[/33#kk%044
	 U?*/>*AEv&vs	
 
&	&#"[[/33#kk%044
	 UGd+5!#E7 +_ _
 	

 QTT	"		"M:44A%++e:L:Q:Q 	{ **,Mr   )1__doc__collections.abcrK   rO   r,   r8   typingr   r   r   r   uint8int8int16int32rT   uint16uint32uint64_INTEGRAL_TYPESfloat16bfloat16rY   float64_FLOATING_TYPESfloat8_e4m3fnfloat8_e5m2float8_e4m3fnuzfloat8_e5m2fnuzrX   	complex32	complex64
complex128rV   rQ   r;   r7   Tensorr+   r   rN   SizelistrI   r   strr   r   r_   rA   r   r   <module>rz      s       ( (  
KK	JJ	KK	KK	KK	LL	LL	LL	 ==%..%--O					  //5??E4D4DE#jj;?; @@@ % %5 % %%,, %   37g#uzz49eCHo=>g;;g #u||#$g 
%	g
 5/g g g g E//0g \\gr   