o
    ϯi{                     @   s   d dl mZmZmZmZ d dlmZ dejejdfdee dee dedee d	e	d
eej
ef fddZded
efddZdS )    )CallableListOptionalTuple)nnNg        fully_connected_dimsnormmid_activationfinal_activationdropout_ratereturnc           
      C   s   t | tsJ t| dksJ tdd | D sJ g }| d }| dd D ]}|t|| |dur<||| ||  |}q&|t|| d  |dkr]|tj|d |durg||  tj| }| d }	||	fS )uW  
    Factory function for Multi-Layer Perceptron. These are constructed as repeated
    blocks of the following format where each fc represents the blocks output/input dimension.

    ::

                             Linear (in=fc[i-1], out=fc[i])
                                           ↓
                                 Normalization (norm)
                                           ↓
                               Activation (mid_activation)
                                           ↓
                            After the repeated Perceptron blocks,
                      a final dropout and activation layer is applied:
                                           ↓
                               Dropout (p=dropout_rate)
                                           ↓
                               Activation (final_activation)

       c                 s   s    | ]}t |V  qd S )N)_is_pos_int).0x r   K/home/ubuntu/.local/lib/python3.10/site-packages/pytorchvideo/layers/mlp.py	<genexpr>%   s    z-make_multilayer_perceptron.<locals>.<genexpr>r   N)p)	
isinstancelistlenallappendr   LinearDropout
Sequential)
r   r   r	   r
   r   layerscur_dimdimmlp
output_dimr   r   r   make_multilayer_perceptron   s&   
r#   numberc                 C   s   t | tko	| dkS )z9
    Returns True if a number is a positive integer.
    r   )typeint)r$   r   r   r   r   :   s   r   )typingr   r   r   r   torchr   ReLUr&   floatModuler#   boolr   r   r   r   r   <module>   s(   
2