U
    yh                     @   s`   d dl Z d dlmZ d dlmZ d dlZd dlZddlmZ G dd deZ	G dd	 d	eZ
dS )
    N)reduce)
deprecated   )Functionc                   @   s0   e Zd Zeededdd Zedd ZdS )Typezt`torch.autograd._functions.Type` is deprecated as of PyTorch 2.1, please use `torch.tensor.to(dtype=dtype)` instead.)categoryc                 C   s(   t || _|jsdn| | _| |S N)type
input_typeZis_cudaZ
get_deviceinput_device)ctxiZ	dest_type r   R/var/www/html/venv/lib/python3.8/site-packages/torch/autograd/_functions/tensor.pyforward   s    
zType.forwardc              
   C   sP   | j dkr|| jd fS tj| j  || jd fW  5 Q R  S Q R X d S r   )r   r
   r   torchcudaZdevicer   Zgrad_outputr   r   r   backward   s    
zType.backwardN)__name__
__module____qualname__staticmethodr   FutureWarningr   r   r   r   r   r   r      s   r   c                   @   s$   e Zd Zedd Zedd ZdS )Resizec                 C   s   || _ ttj|d| _| | jkrZtddtt	|| jdtt	|
 | |
 | _|jr|| | j| S | r|| j| }|S | j| S d S )N   zrequested resize to {} ({} elements in total), but the given tensor has a size of {} ({} elements). autograd's resize can only change the shape of a given tensor, while preserving the number of elements. x)sizesr   operatormulnumelRuntimeErrorformatjoinmapstrsizeinput_sizesZis_quantizedZcopy_
contiguousviewZis_contiguousnew)r   Ztensorr   resultr   r   r   r   "   s(    

zResize.forwardc                 C   s&   |  | j kst| | jd fS )N)r!   AssertionErrorr)   r*   r(   r   r   r   r   r   >   s    zResize.backwardN)r   r   r   r   r   r   r   r   r   r   r   !   s   
r   )r   	functoolsr   typing_extensionsr   r   Ztorch._utilsfunctionr   r   r   r   r   r   r   <module>   s   