U
    ­Ê¹jæ€  ã                	   @   sÈ  d dl Z d dlmZ d dlmZ d dlmZmZmZm	Z	m
Z
mZmZ d dlZd dlZd dlmZ ddlmZmZ ddlmZ ddlmZ d	d
lmZmZmZ d	dlmZ d	dlmZm Z  dddddgZ!eG dd„ dƒƒZ"ee# e#dœdd„Z$ej%e#e#eej%e#f dœdd„Z&ej%e#e#e#ej%dœdd„Z'ej( )d¡ ej( )d¡ G dd„ dej*ƒZ+ej%e#ej%dœd d!„Z,ej%ej%ee#e#e#f ee#e#e#f ej%ej%ej%ej%d"œd#d$„Z-ej%ej%e.d%œd&d'„Z/ej( )d$¡ ej( )d'¡ G d(d)„ d)ej*ƒZ0G d*d+„ d+ej*ƒZ1G d,d-„ d-ej*ƒZ2G d.d„ dej*ƒZ3e	e" e4e
e e.ee3d/œd0d1„Z5G d2d„ deƒZ6G d3d„ deƒZ7eƒ e d4e6j8fd5�dd6d7œe
e6 e.ee3d8œd9d„ƒƒZ9eƒ e d4e7j8fd5�dd6d7œe
e7 e.ee3d8œd:d„ƒƒZ:dS );é    N)Ú	dataclass)Úpartial)ÚAnyÚCallableÚDictÚListÚOptionalÚSequenceÚTupleé   )ÚMLPÚStochasticDepth)ÚVideoClassification)Ú_log_api_usage_onceé   )Úregister_modelÚWeightsÚWeightsEnum)Ú_KINETICS400_CATEGORIES)Ú_ovewrite_named_paramÚhandle_legacy_interfaceÚMViTÚMViT_V1_B_WeightsÚ	mvit_v1_bÚMViT_V2_S_WeightsÚ	mvit_v2_sc                   @   sV   e Zd ZU eed< eed< eed< ee ed< ee ed< ee ed< ee ed< dS )	ÚMSBlockConfigÚ	num_headsÚinput_channelsÚoutput_channelsÚkernel_qÚ	kernel_kvÚstride_qÚ	stride_kvN)Ú__name__Ú
__module__Ú__qualname__ÚintÚ__annotations__r   © r)   r)   ú\/var/www/html/bwave/python/venv/lib/python3.8/site-packages/torchvision/models/video/mvit.pyr      s   
r   )ÚsÚreturnc                 C   s   d}| D ]}||9 }q|S ©Né   r)   )r+   ÚproductÚvr)   r)   r*   Ú_prod&   s    
r1   )ÚxÚ
target_dimÚ
expand_dimr,   c                 C   s@   |   ¡ }||d kr |  |¡} n||kr8td| j› �ƒ‚| |fS )Nr.   zUnsupported input dimension )ÚdimÚ	unsqueezeÚ
ValueErrorÚshape©r2   r3   r4   Ú
tensor_dimr)   r)   r*   Ú
_unsqueeze-   s    r;   )r2   r3   r4   r:   r,   c                 C   s   ||d kr|   |¡} | S r-   )Úsqueezer9   r)   r)   r*   Ú_squeeze6   s    
r=   c                       sl   e Zd Zd	ejeej eej eddœ‡ fdd„Zej	e
eeef e
ej	e
eeef f dœdd„Z‡  ZS )
ÚPoolNF)ÚpoolÚnormÚ
activationÚnorm_before_poolr,   c                    sV   t ƒ  ¡  || _g }|d k	r&| |¡ |d k	r8| |¡ |rFtj|Ž nd | _|| _d S )N)ÚsuperÚ__init__r?   ÚappendÚnnÚ
SequentialÚnorm_actrB   )Úselfr?   r@   rA   rB   Úlayers©Ú	__class__r)   r*   rD   A   s    


zPool.__init__©r2   Úthwr,   c                 C   sö   t |ddƒ\}}tj|ddd�\}}| dd¡}|jd d… \}}}| || |f| ¡ ¡ }| jrx| jd k	rx|  |¡}|  	|¡}|jdd … \}}	}
| |||d¡ dd¡}tj
||fdd�}| jsÚ| jd k	rÚ|  |¡}t|dd|ƒ}|||	|
ffS )	Né   r.   ©r.   r   )Úindicesr5   r   éÿÿÿÿ©r5   )r;   ÚtorchZtensor_splitÚ	transposer8   ÚreshapeÚ
contiguousrB   rH   r?   Úcatr=   )rI   r2   rN   r:   Úclass_tokenÚBÚNÚCÚTÚHÚWr)   r)   r*   ÚforwardR   s    


zPool.forward)NF)r$   r%   r&   rF   ÚModuler   ÚboolrD   rT   ÚTensorr
   r'   r`   Ú__classcell__r)   r)   rK   r*   r>   @   s     ûúr>   )Ú	embeddingÚdr,   c                 C   s@   | j d |kr| S tjj|  dd¡ d¡|dd� d¡ dd¡S )Nr   r.   Zlinear)ÚsizeÚmode)r8   rF   Z
functionalZinterpolateÚpermuter6   r<   )re   rf   r)   r)   r*   Ú_interpolatel   s    ýû úÿrj   )ÚattnÚqÚq_thwÚk_thwÚ	rel_pos_hÚ	rel_pos_wÚ	rel_pos_tr,   c           %      C   s6  |\}}}	|\}
}}t dt||ƒ d ƒ}t dt|	|ƒ d ƒ}t dt||
ƒ d ƒ}t|| dƒ}t|| dƒ}t |¡d d …d f | t |¡d d d …f d|  |  }t||	 dƒ}t|	| dƒ}t |	¡d d …d f | t |¡d d d …f d|  |  }t|
| dƒ}t||
 dƒ}t |¡d d …d f | t |
¡d d d …f d|
  |  }t||ƒ}t||ƒ}t||ƒ}|| ¡  }|| ¡  }|| ¡  }|j\}}}}|d d …d d …dd …f  |||||	|¡} t d| |¡}!t d| |¡}"|  	dddddd	¡ ||| | |	 |¡} t 
| | dd¡¡ dd¡}#|# ||||	||
¡ 	dddddd	¡}#|!d d …d d …d d …d d …d d …d d d …d f |"d d …d d …d d …d d …d d …d d d d …f  |#d d …d d …d d …d d …d d …d d …d d f   |||| |	 |
| | ¡}$| d d …d d …dd …dd …f  |$7  < | S )
Nr   r.   ç      ð?zbythwc,hkc->bythwkzbythwc,wkc->bythwkr   r   rO   é   )r'   ÚmaxrT   Zarangerj   Úlongr8   rV   Zeinsumri   ÚmatmulrU   Úview)%rk   rl   rm   rn   ro   rp   rq   Zq_tZq_hZq_wZk_tZk_hZk_wZdhZdwÚdtZ	q_h_ratioZ	k_h_ratioZdist_hZ	q_w_ratioZ	k_w_ratioZdist_wZ	q_t_ratioZ	k_t_ratioZdist_tZRhZRwZRtrZ   Zn_headÚ_r5   Zr_qZrel_h_qZrel_w_qZrel_q_tZrel_posr)   r)   r*   Ú_add_rel_pos{   sP    


<<<


**$..ÿ.þ  
 
ýÿ(rz   ©r2   ZshortcutÚresidual_with_cls_embedc              	   C   sX   |r|   |¡ nD| d d …d d …dd …d d …f  |d d …d d …dd …d d …f 7  < | S r-   )Úadd_r{   r)   r)   r*   Ú_add_shortcut·   s    Dr~   c                       s”   e Zd Zdejfee eeeee ee ee ee eeeee	dej
f ddœ‡ fdd„Zejeeeef eejeeeef f dœdd	„Z‡  ZS )
ÚMultiscaleAttentionç        .N)Ú
input_sizeÚ	embed_dimÚ
output_dimr   r    r!   r"   r#   Úresidual_poolr|   Úrel_pos_embedÚdropoutÚ
norm_layerr,   c              
      st  t ƒ  ¡  || _|| _|| _|| | _dt | j¡ | _|	| _	|
| _
t |d| ¡| _t ||¡g}|dkr€| tj|dd�¡ tj|Ž | _d | _t|ƒdksªt|ƒdkrädd„ |D ƒ}ttj| j| j|||| jd	d
�|| jƒƒ| _d | _d | _t|ƒdk�st|ƒdk�rrdd„ |D ƒ}ttj| j| j|||| jd	d
�|| jƒƒ| _ttj| j| j|||| jd	d
�|| jƒƒ| _d | _d | _d | _|�rpt|dd … ƒ}t|ƒdk�r´||d  n|}t|ƒdk�rÒ||d  n|}dt||ƒ d }d|d  d }t t || j¡¡| _t t || j¡¡| _t t || j¡¡| _tj j!| jdd� tj j!| jdd� tj j!| jdd� d S )Nrr   r   r€   T©Úinplacer.   c                 S   s   g | ]}t |d  ƒ‘qS ©r   ©r'   )Ú.0rl   r)   r)   r*   Ú
<listcomp>å   s     z0MultiscaleAttention.__init__.<locals>.<listcomp>F)ÚstrideÚpaddingÚgroupsÚbiasc                 S   s   g | ]}t |d  ƒ‘qS rŠ   r‹   )rŒ   Úkvr)   r)   r*   r�   ö   s     r   r   ç{®Gáz”?©Ústd)"rC   rD   r‚   rƒ   r   Úhead_dimÚmathÚsqrtÚscalerr„   r|   rF   ÚLinearÚqkvrE   ÚDropoutrG   ÚprojectÚpool_qr1   r>   ÚConv3dÚpool_kÚpool_vro   rp   rq   rt   ÚlenÚ	ParameterrT   ÚzerosÚinitÚtrunc_normal_)rI   r�   r‚   rƒ   r   r    r!   r"   r#   r„   r|   r…   r†   r‡   rJ   Z	padding_qZ
padding_kvrg   Zq_sizeZkv_sizeZspatial_dimZtemporal_dimrK   r)   r*   rD   Ä   sŽ    

ù	öù	öù	özMultiscaleAttention.__init__rM   c                 C   s<  |j \}}}|  |¡ ||d| j| j¡ dd¡jdd�\}}}| jd k	rZ|  ||¡\}}	n|}	| jd k	rx|  ||¡d }| j	d k	r’|  	||¡\}}t
 | j| | dd¡¡}
| jd k	rä| jd k	rä| jd k	rät|
|||	| j| j| jƒ}
|
jdd�}
t
 |
|¡}| j�rt||| jƒ | dd¡ |d| j¡}|  |¡}||fS )Nr   r.   r   rS   r   rR   )r8   r›   rV   r   r–   rU   Zunbindr    r¡   rž   rT   rv   r™   ro   rp   rq   rz   Zsoftmaxr„   r~   r|   rƒ   r�   )rI   r2   rN   rZ   r[   r\   rl   Úkr0   rn   rk   r)   r)   r*   r`      s6    2


ù	
zMultiscaleAttention.forward)r$   r%   r&   rF   Ú	LayerNormr   r'   rb   Úfloatr   ra   rD   rT   rc   r
   r`   rd   r)   r)   rK   r*   r   Ã   s&   òñ\r   c                       s~   e Zd Zddejfee eeeeee	e	e
dejf ddœ
‡ fdd„Zejeeeef eejeeeef f dœdd	„Z‡  ZS )
ÚMultiscaleBlockr€   .N)
r�   Úcnfr„   r|   r…   Úproj_after_attnr†   Ústochastic_depth_probr‡   r,   c
                    s  t ƒ  ¡  || _d | _t|jƒdkr\dd„ |jD ƒ}
dd„ |
D ƒ}ttj|
|j|d�d ƒ| _|rf|j	n|j
}|	|j
ƒ| _|	|ƒ| _t| jtjƒ| _t||j
||j|j|j|j|j|||||	d�| _t|d| |j	gtj|d d�| _t|d	ƒ| _d | _|j
|j	k�rt |j
|j	¡| _d S )
Nr.   c                 S   s    g | ]}|d kr|d  n|‘qS rP   r)   )rŒ   r+   r)   r)   r*   r�   U  s     z,MultiscaleBlock.__init__.<locals>.<listcomp>c                 S   s   g | ]}t |d  ƒ‘qS rŠ   r‹   )rŒ   r§   r)   r)   r*   r�   V  s     )rŽ   r�   )	r    r!   r"   r#   r…   r„   r|   r†   r‡   rO   )Zactivation_layerr†   r‰   Úrow)rC   rD   r¬   Ú	pool_skipr1   r"   r>   rF   Z	MaxPool3dr   r   Únorm1Únorm2Ú
isinstanceZBatchNorm1dÚneeds_transposalr   r   r    r!   r#   rk   r   ZGELUÚmlpr   Ústochastic_depthr�   rš   )rI   r�   r«   r„   r|   r…   r¬   r†   r­   r‡   Zkernel_skipZpadding_skipZattn_dimrK   r)   r*   rD   D  sP    
 ÿ
óûzMultiscaleBlock.__init__rM   c           	      C   sä   | j r |  | dd¡¡ dd¡n|  |¡}|  ||¡\}}| jd ksJ| jsN|n|  |¡}| jd krf|n|  ||¡d }||  |¡ }| j r¤|  | dd¡¡ dd¡n|  |¡}| jd ks¾| jrÂ|n|  |¡}||  |  	|¡¡ |fS )Nr.   r   r   )
r³   r°   rU   rk   r�   r¬   r¯   rµ   r±   r´   )	rI   r2   rN   Zx_norm1Zx_attnZthw_newZx_skipZx_norm2Zx_projr)   r)   r*   r`   ~  s    **zMultiscaleBlock.forward)r$   r%   r&   rF   r¨   r   r'   r   rb   r©   r   ra   rD   rT   rc   r
   r`   rd   r)   r)   rK   r*   rª   C  s    	öõ:rª   c                       sF   e Zd Zeeeef eeddœ‡ fdd„Zejejdœdd„Z	‡  Z
S )ÚPositionalEncodingN)Ú
embed_sizeÚspatial_sizeÚtemporal_sizer…   r,   c                    sŽ   t ƒ  ¡  || _|| _t t |¡¡| _d | _	d | _
d | _|sŠt t | jd | jd  |¡¡| _	t t | j|¡¡| _
t t |¡¡| _d S )Nr   r.   )rC   rD   r¸   r¹   rF   r£   rT   r¤   rY   Úspatial_posÚtemporal_posÚ	class_pos)rI   r·   r¸   r¹   r…   rK   r)   r*   rD   Œ  s    
$zPositionalEncoding.__init__©r2   r,   c                 C   s¼   | j  | d¡d¡ d¡}tj||fdd�}| jd k	r¸| jd k	r¸| jd k	r¸| jj	\}}tj
| j|dd�}| | j d¡ | jdd¡ d|¡¡ tj| j d¡|fdd� d¡}| |¡ |S )Nr   rR   r.   rS   )rY   Úexpandrg   r6   rT   rX   rº   r»   r¼   r8   Zrepeat_interleaver}   r¹   rV   )rI   r2   rY   Zhw_sizer·   Zpos_embeddingr)   r)   r*   r`   š  s    & 
zPositionalEncoding.forward)r$   r%   r&   r'   r
   rb   rD   rT   rc   r`   rd   r)   r)   rK   r*   r¶   ‹  s   "r¶   c                       sž   e Zd Zdeeef eee eeeeeeeee	e
dejf  e	e
dejf  eeeef eeeef eeeef dd	œ‡ fd
d„Zejejdœdd„Z‡  ZS )r   ç      à?r€   é�  N©r   é   rÂ   ©r   rO   rO   ©r.   r   r   .)r¸   r¹   Úblock_settingr„   r|   r…   r¬   r†   Úattention_dropoutr­   Únum_classesÚblockr‡   Úpatch_embed_kernelÚpatch_embed_strideÚpatch_embed_paddingr,   c                    s*  t ƒ  ¡  t| ƒ t|ƒ}|dkr*tdƒ‚|dkr6t}|dkrLttjdd�}tj	d|d j
|||d�| _dd	„ t|f| | jjƒD ƒ}t|d j
|d
 |d f|d |d�| _t ¡ | _t|ƒD ]^\}}|
| |d  }| j ||||||||	||d�	¡ t|jƒdkrÀdd	„ t||jƒD ƒ}qÀ||d jƒ| _t tj|dd�t |d j|¡¡| _|  ¡ D ]Æ}t|tjƒ�r®tjj|jdd� t|tjƒ�r"|j dk	�r"tj !|j d¡ ntt|tjƒ�rö|jdk	�rØtj !|jd¡ |j dk	�r"tj !|j d¡ n,t|tƒ�r^| "¡ D ]}tjj|dd� �q
�q^dS )aÄ  
        MViT main class.

        Args:
            spatial_size (tuple of ints): The spacial size of the input as ``(H, W)``.
            temporal_size (int): The temporal size ``T`` of the input.
            block_setting (sequence of MSBlockConfig): The Network structure.
            residual_pool (bool): If True, use MViTv2 pooling residual connection.
            residual_with_cls_embed (bool): If True, the addition on the residual connection will include
                the class embedding.
            rel_pos_embed (bool): If True, use MViTv2's relative positional embeddings.
            proj_after_attn (bool): If True, apply the projection after the attention.
            dropout (float): Dropout rate. Default: 0.0.
            attention_dropout (float): Attention dropout rate. Default: 0.0.
            stochastic_depth_prob: (float): Stochastic depth rate. Default: 0.0.
            num_classes (int): The number of classes.
            block (callable, optional): Module specifying the layer which consists of the attention and mlp.
            norm_layer (callable, optional): Module specifying the normalization layer to use.
            patch_embed_kernel (tuple of ints): The kernel of the convolution that patchifies the input.
            patch_embed_stride (tuple of ints): The stride of the convolution that patchifies the input.
            patch_embed_padding (tuple of ints): The padding of the convolution that patchifies the input.
        r   z+The configuration parameter can't be empty.Ng�íµ ÷Æ°>)Úepsr   )Zin_channelsZout_channelsZkernel_sizerŽ   r�   c                 S   s   g | ]\}}|| ‘qS r)   r)   ©rŒ   rg   rŽ   r)   r)   r*   r�   ë  s     z!MViT.__init__.<locals>.<listcomp>r.   r   )r·   r¸   r¹   r…   rr   )	r�   r«   r„   r|   r…   r¬   r†   r­   r‡   c                 S   s   g | ]\}}|| ‘qS r)   r)   rÍ   r)   r)   r*   r�   
  s     rR   Trˆ   r“   r”   r€   )#rC   rD   r   r¢   r7   rª   r   rF   r¨   rŸ   r   Ú	conv_projÚziprŽ   r¶   Úpos_encodingZ
ModuleListÚblocksÚ	enumeraterE   r"   r   r@   rG   rœ   rš   ÚheadÚmodulesr²   r¥   r¦   Úweightr‘   Z	constant_Ú
parameters)rI   r¸   r¹   rÅ   r„   r|   r…   r¬   r†   rÆ   r­   rÇ   rÈ   r‡   rÉ   rÊ   rË   Ztotal_stage_blocksr�   Zstage_block_idr«   Zsd_probÚmÚweightsrK   r)   r*   rD   ©  sv    )
ûü
÷ÿþzMViT.__init__r½   c                 C   sŠ   t |ddƒd }|  |¡}| d¡ dd¡}|  |¡}| jjf| jj }| jD ]}|||ƒ\}}qN|  |¡}|d d …df }|  	|¡}|S )Nrs   r   r   r.   )
r;   rÎ   ÚflattenrU   rÐ   r¹   r¸   rÑ   r@   rÓ   )rI   r2   rN   rÈ   r)   r)   r*   r`   !  s    




zMViT.forward)	r¿   r€   r€   rÀ   NNrÁ   rÃ   rÄ   )r$   r%   r&   r
   r'   r	   r   rb   r©   r   r   rF   ra   rD   rT   rc   r`   rd   r)   r)   rK   r*   r   ¨  s:   
         ï
îx)rÅ   r­   rØ   ÚprogressÚkwargsr,   c                 K   sÚ   |d k	rbt |dt|jd ƒƒ |jd d |jd d ks>t‚t |d|jd ƒ t |d|jd ƒ | dd	¡}| dd
¡}tf ||| | dd¡| dd¡| dd¡| dd¡|dœ|—Ž}|d k	rÖ| |j|dd�¡ |S )NrÇ   Ú
categoriesÚmin_sizer   r.   r¸   r¹   Úmin_temporal_size©éà   rà   é   r„   Fr|   Tr…   r¬   )r¸   r¹   rÅ   r„   r|   r…   r¬   r­   )rÚ   Z
check_hash)r   r¢   ÚmetaÚAssertionErrorÚpopr   Zload_state_dictZget_state_dict)rÅ   r­   rØ   rÚ   rÛ   r¸   r¹   Úmodelr)   r)   r*   Ú_mvit8  s,     



ø	÷ræ   c                   @   sJ   e Zd Zedeeddddd�ddedd	d
ddddœidddœ	d�ZeZdS )r   z:https://download.pytorch.org/models/mvit_v1_b-dbeb1030.pthrß   ©é   ©çÍÌÌÌÌÌÜ?rê   rê   ©çÍÌÌÌÌÌÌ?rì   rì   ©Z	crop_sizeZresize_sizeZmeanr•   rá   zShttps://github.com/facebookresearch/pytorchvideo/blob/main/docs/source/model_zoo.mdúœThe weights were ported from the paper. The accuracies are estimated on video-level with parameters `frame_rate=7.5`, `clips_per_video=5`, and `clip_len=16`ip¢.úKinetics-400gJ+‡žS@gh‘í|?eW@©zacc@1zacc@5gu“V¦Q@gœÄ °rxa@©	rÝ   rÞ   rÜ   ZrecipeZ_docsZ
num_paramsZ_metricsZ_opsÚ
_file_size©ÚurlZ
transformsrâ   N©	r$   r%   r&   r   r   r   r   ÚKINETICS400_V1ÚDEFAULTr)   r)   r)   r*   r   Y  s2   ûþÿï÷c                   @   sJ   e Zd Zedeeddddd�ddedd	d
ddddœidddœ	d�ZeZdS )r   z:https://download.pytorch.org/models/mvit_v2_s-ae3be167.pthrß   rç   ré   rë   rí   rá   zChttps://github.com/facebookresearch/SlowFast/blob/main/MODEL_ZOO.mdrî   irï   gœÄ °r0T@gÃõ(\�ªW@rð   gu“VP@g?5^ºI|`@rñ   ró   Nrõ   r)   r)   r)   r*   r   z  s2   ûþÿï÷Z
pretrained)rØ   T)rØ   rÚ   )rØ   rÚ   rÛ   r,   c                 K   sz  t  | ¡} ddddddddddddddddgddddddddddddddddgddddddddddddddddgg d	d	d	gg d	d	d	gg g g g g g g g g g d	d	d	gg gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	ggg dddgg dddgg g g g g g g g g g dddgg gdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddggd
œ}g }tt|d ƒƒD ]Z}| t|d | |d | |d | |d | |d | |d | |d | d
�¡ �qötf dd|dd| dd¡| |dœ|—ŽS )a¿  
    Constructs a base MViTV1 architecture from
    `Multiscale Vision Transformers <https://arxiv.org/abs/2104.11227>`__.

    .. betastatus:: video module

    Args:
        weights (:class:`~torchvision.models.video.MViT_V1_B_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.video.MViT_V1_B_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.video.MViT``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/video/mvit.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.video.MViT_V1_B_Weights
        :members:
    r.   r   rO   é   é`   éÀ   é€  é   r   ©r   r   r   r    r!   r"   r#   r   r   r   r    r!   r"   r#   rß   rá   Fr­   çš™™™™™É?)r¸   r¹   rÅ   r„   r|   r­   rØ   rÚ   )r   ÚverifyÚranger¢   rE   r   ræ   rä   ©rØ   rÚ   rÛ   ÚconfigrÅ   Úir)   r)   r*   r   ›  s„    
"""4ð4ðè,






ùÿ
ø	÷c                 K   s  t  | ¡} ddddddddddddddddgddddddddddddddddgddddddddddddddddgd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	ggd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	gd	d	d	ggdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddggdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddggd
œ}g }tt|d ƒƒD ]Z}| t|d | |d | |d | |d | |d | |d | |d | d
�¡ �q’tf dd|dddd| dd¡| |dœ
|—ŽS )aC  Constructs a small MViTV2 architecture from
    `Multiscale Vision Transformers <https://arxiv.org/abs/2104.11227>`__ and
    `MViTv2: Improved Multiscale Vision Transformers for Classification
    and Detection <https://arxiv.org/abs/2112.01526>`__.

    .. betastatus:: video module

    Args:
        weights (:class:`~torchvision.models.video.MViT_V2_S_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.video.MViT_V2_S_Weights` below for
            more details, and possible values. By default, no pre-trained
            weights are used.
        progress (bool, optional): If True, displays a progress bar of the
            download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.video.MViT``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/video/mvit.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.video.MViT_V2_S_Weights
            :members:
    r.   r   rO   rø   rù   rú   rû   rü   r   rý   r   r   r   r    r!   r"   r#   rß   rá   TFr­   rþ   )
r¸   r¹   rÅ   r„   r|   r…   r¬   r­   rØ   rÚ   )r   rÿ   r   r¢   rE   r   ræ   rä   r  r)   r)   r*   r   ý  sÈ    
"""ððððÆN






ùÿ
öõ);r—   Údataclassesr   Ú	functoolsr   Útypingr   r   r   r   r   r	   r
   rT   Ztorch.fxZtorch.nnrF   Zopsr   r   Ztransforms._presetsr   Úutilsr   Z_apir   r   r   Ú_metar   Z_utilsr   r   Ú__all__r   r'   r1   rc   r;   r=   ZfxÚwrapra   r>   rj   rz   rb   r~   r   rª   r¶   r   r©   ræ   r   r   rö   r   r   r)   r)   r)   r*   Ú<module>   sx   $û	
 	,ø< H ú!!!$`