a
    áñhþ  ã                   @   s–   d Z ddlZddlZddlmZmZ ddlmZmZmZ G dd„ dej	j
ƒZ
G dd„ dej	jƒZG d	d
„ d
ej	jƒZej	jjZG dd„ dej	jƒZdS )zè
helper class that supports empty tensors on some nn functions.

Ideally, add support directly in PyTorch to empty tensors in
those functions.

This can be removed once https://github.com/pytorch/pytorch/issues/12013
is implemented
é    N)ÚTensorÚSize)ÚListÚOptionalÚTuplec                       s   e Zd Z‡ fdd„Z‡  ZS )ÚConv2dc                    s"   t ƒ j|i |¤Ž t dt¡ d S )Nzntorchvision.ops.misc.Conv2d is deprecated and will be removed in future versions, use torch.nn.Conv2d instead.©ÚsuperÚ__init__ÚwarningsÚwarnÚFutureWarning©ÚselfÚargsÚkwargs©Ú	__class__© úT/home/yuhw/wc/uboone-dl-vtx/venv/lib/python3.9/site-packages/torchvision/ops/misc.pyr
      s
    þzConv2d.__init__©Ú__name__Ú
__module__Ú__qualname__r
   Ú__classcell__r   r   r   r   r      s   r   c                       s   e Zd Z‡ fdd„Z‡  ZS )ÚConvTranspose2dc                    s"   t ƒ j|i |¤Ž t dt¡ d S )Nz€torchvision.ops.misc.ConvTranspose2d is deprecated and will be removed in future versions, use torch.nn.ConvTranspose2d instead.r   r   r   r   r   r
      s
    þzConvTranspose2d.__init__r   r   r   r   r   r      s   r   c                       s   e Zd Z‡ fdd„Z‡  ZS )ÚBatchNorm2dc                    s"   t ƒ j|i |¤Ž t dt¡ d S )Nzxtorchvision.ops.misc.BatchNorm2d is deprecated and will be removed in future versions, use torch.nn.BatchNorm2d instead.r   r   r   r   r   r
   "   s
    þzBatchNorm2d.__init__r   r   r   r   r   r   !   s   r   c                       sx   e Zd ZdZdeeee dœ‡ fdd„Zee	ee
ee	 ee	 ee	 dœ‡ fdd	„Zeed
œdd„Ze	dœdd„Z‡  ZS )ÚFrozenBatchNorm2dzX
    BatchNorm2d where the batch statistics and the affine parameters
    are fixed
    ç        N)Únum_featuresÚepsÚnc                    sx   |d urt  dt¡ |}tt| ƒ ¡  || _|  dt 	|¡¡ |  dt 
|¡¡ |  dt 
|¡¡ |  dt 	|¡¡ d S )Nz>`n` argument is deprecated and has been renamed `num_features`ÚweightÚbiasÚrunning_meanÚrunning_var)r   r   ÚDeprecationWarningr	   r   r
   r    Zregister_bufferÚtorchZonesÚzeros)r   r   r    r!   r   r   r   r
   3   s    ÿzFrozenBatchNorm2d.__init__)Ú
state_dictÚprefixÚlocal_metadataÚstrictÚmissing_keysÚunexpected_keysÚ
error_msgsc           	   	      s6   |d }||v r||= t t| ƒ |||||||¡ d S )NZnum_batches_tracked)r	   r   Ú_load_from_state_dict)	r   r)   r*   r+   r,   r-   r.   r/   Znum_batches_tracked_keyr   r   r   r0   E   s    

þz'FrozenBatchNorm2d._load_from_state_dict)ÚxÚreturnc                 C   sr   | j  dddd¡}| j dddd¡}| j dddd¡}| j dddd¡}||| j  ¡  }|||  }|| | S )Né   éÿÿÿÿ)r"   Zreshaper#   r%   r$   r    Zrsqrt)r   r1   ÚwÚbÚrvZrmZscaler#   r   r   r   ÚforwardW   s    zFrozenBatchNorm2d.forward)r2   c                 C   s   | j j› d| jjd › d�S )Nú(r   ú))r   r   r"   Úshape)r   r   r   r   Ú__repr__b   s    zFrozenBatchNorm2d.__repr__)r   N)r   r   r   Ú__doc__ÚintÚfloatr   r
   ÚdictÚstrÚboolr   r0   r   r8   r<   r   r   r   r   r   r   -   s$     üüør   )r=   r   r'   r   r   Ztorch.jit.annotationsr   r   r   Únnr   r   r   Z
functionalZinterpolateÚModuler   r   r   r   r   Ú<module>   s   

