o
    Zh                     @   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   O/var/www/auris/lib/python3.10/site-packages/torch/autograd/_functions/tensor.pyforward   s   

zType.forwardc                 C   s\   | j dkr|| jd fS tj| j  || jd fW  d    S 1 s'w   Y  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r-tddtt	|| jdtt	|
 | |
 | _|jrA|| | j| S | rQ|| j| }|S | j| 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	J | | jd fS )N)r    r(   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   Ztyping_extensionsr   r   Ztorch._utilsZtorch.autograd.functionr   r   r   r   r   r   r   <module>   s   