o
    þÏ¯iÛ  ã                   @   sB   d dl Z d dlmZ ddee ddfdd„Zdd	d
„Zdd„ ZdS )é    N)ÚListÚparamsÚreturnc                 C   s2   |r|  ¡ D ]\}}|dkrt| ||ƒ qdS dS )z—
    An utility function used in classes to set attributes from the input list of parameters.
    Args:
        params (list): list of parameters.
    ÚselfN)ÚitemsÚsetattr)r   r   ÚkÚv© r
   úM/home/ubuntu/.local/lib/python3.10/site-packages/pytorchvideo/layers/utils.pyÚset_attributes   s   €ýr   é   Fc                 C   st   |s| S | |9 } |p|}|rt |tt | | ¡ƒ| ƒ}nt |t| |d  ƒ| | ƒ}|d|  k r6||7 }t|ƒS )a}  
    Round width of filters based on width multiplier
    Args:
        width (int): the channel dimensions of the input.
        multiplier (float): the multiplication factor.
        min_width (int): the minimum width after multiplication.
        divisor (int): the new width should be dividable by divisor.
        ceil (bool): If True, use ceiling as the rounding method.
    é   gÍÌÌÌÌÌì?)ÚmaxÚintÚmathÚceil)ÚwidthÚ
multiplierÚ	min_widthÚdivisorr   Ú	width_outr
   r
   r   Úround_width   s   
r   c                 C   s   |s| S t t ||  ¡ƒS )z;
    Round number of layers based on depth multiplier.
    )r   r   r   )Úrepeatsr   r
   r
   r   Úround_repeats+   s   r   )N)r   r   F)r   Útypingr   Úobjectr   r   r   r
   r
   r
   r   Ú<module>   s
   
