a
    8Sic|                  
   @   sv  d Z ddlZddlZddlZddlmZmZmZmZm	Z	m
Z
 ddlZddlmZ g dZe
eeee	edf eeef egef f edd	d
ZedejZedejZejdejdejdiZejeje	eef dddZeddeeee ee eeddddZdd ZejD ],ZeeeZ eee e! e< e"e qeeej#Z#edejejdddZ$dS ) a;  This module exists since the `torch.testing` exposed a lot of stuff that shouldn't have been public. Although this
was never documented anywhere, some other internal FB projects as well as downstream OSS projects might use this. Thus,
we don't internalize without warning, but still go through a deprecation cycle.
    N)AnyCallableDictOptionalTupleUnion   )_legacy)randrandnassert_allcloseget_all_device_typesmake_non_contiguous.)instructionsreturnc                    s   t t d fdd}|S )N)fnr   c                    s<    j d dt tttd fdd}|S )Nztorch.testing.z9() is deprecated since 1.12 and will be removed in 1.14. )argskwargsr   c                     sD    | i |}t r$| ||n}|  }t|t |S )N)callablestripwarningswarnFutureWarning)r   r   return_valuetailmsg)r   headr   name U/var/www/html/django/DPS/env/lib/python3.9/site-packages/torch/testing/_deprecated.pyinner_wrapper   s
    z=warn_deprecated.<locals>.outer_wrapper.<locals>.inner_wrapper)__name__	functoolswrapsr   )r   r    r   )r   r   r   r   outer_wrapper   s
    z&warn_deprecated.<locals>.outer_wrapper)r   )r   r%   r   r$   r   warn_deprecated   s    r&   zUse torch.rand() instead.zUse torch.randn() instead.)MbP?r'   )g-C6?h㈵>)r(   g:0yE>)actualexpectedr   c                 C   s8   t | jd\}}t |jd\}}t||t||fS )N)        r+   )_DTYPE_PRECISIONSgetdtypemax)r)   r*   Zactual_rtolZactual_atolZexpected_rtolZexpected_atolr   r   r   _get_default_rtol_and_atol6   s    r0   zUse torch.testing.assert_close() instead. For detailed upgrade instructions see https://github.com/pytorch/pytorch/issues/61844.T )r)   r*   rtolatol	equal_nanr   r   c                 C   sv   t | tjst| } t |tjs2tj|| jd}|d u rP|d u rPt| |\}}tjj| ||||ddd|pld d	 d S )N)r.   TF)r2   r3   r4   check_devicecheck_dtypecheck_strider   )
isinstancetorchTensortensorr.   r0   testingassert_close)r)   r*   r2   r3   r4   r   r   r   r   r   <   s"    
r   c                 C   s   d| dS )NzThis call can be replaced with .r   )r   r   r   r   r   r   r   <lambda>^       r?   a+  Depending on the use case there a different replacement options:

- If you are using `make_non_contiguous` in combination with a creation function to create a noncontiguous tensor with random values, use `torch.testing.make_tensor(..., noncontiguous=True)` instead.
- If you are using `make_non_contiguous` with a specific tensor, you can replace this call with `torch.repeat_interleave(input, 2, dim=-1)[..., ::2]`.
- If you are using `make_non_contiguous` in the PyTorch test suite, use `torch.testing._internal.common_utils.noncontiguous_like` instead.)r;   r   c              	   C   s  |   dkr|  S t|  }tdD ]4}tdt|d }tdd}|| | ||< q(| t	
|tddg }|t| d tdd}tt|D ]H}||| |krtd||| | }|||| |}q||  |jS )Nr      r            )numelclonelistsizerangerandomrandintlennewr9   Sizeselectnarrowcopy_data)r;   Zosize_dimaddinputiboundsr   r   r   r   j   s    
 
r   )NNTr1   )%__doc__r"   rJ   r   typingr   r   r   r   r   r   r9   r1   r	   __all__strr&   r
   r   float16float32float64r,   r:   floatr0   boolr   Zgetter_instructionsZ__all_dtype_getters__r   getattrr   globalsappendr   r   r   r   r   r   <module>   sT    	8    

	