o
    ÓÙ¾i  ã                   @   sZ   d Z ddlmZ ddlZdd„ ZedƒZedƒZedƒZed	ƒZ	eZ
ddd„Zdd„ ZdS )zI Layer/Module Helpers

Hacked together by / Copyright 2020 Ross Wightman
é    )ÚrepeatNc                    s   ‡ fdd„}|S )Nc                    s.   t | tjjƒrt | tƒst| ƒS tt| ˆ ƒƒS )N)Ú
isinstanceÚcollectionsÚabcÚIterableÚstrÚtupler   )Úx©Ún© úG/home/ubuntu/.local/lib/python3.10/site-packages/timm/layers/helpers.pyÚparse   s   z_ntuple.<locals>.parser   )r   r   r   r
   r   Ú_ntuple
   s   r   é   é   é   é   é   çÍÌÌÌÌÌì?c                 C   s>   |p|}t |t| |d  ƒ| | ƒ}|||  k r||7 }|S )Nr   )ÚmaxÚint)ÚvÚdivisorÚ	min_valueÚround_limitÚnew_vr   r   r   Úmake_divisible   s
   r   c                 C   sP   t | ttfƒs| f} nt| ƒ} |t| ƒ }|dkr| d |… S | | d f|  S )Nr   éÿÿÿÿ)r   r   ÚlistÚlen)r	   r   Úpad_nr   r   r   Úextend_tuple"   s   r"   )r   Nr   )Ú__doc__Ú	itertoolsr   Úcollections.abcr   r   Ú	to_1tupleÚ	to_2tupleÚ	to_3tupleÚ	to_4tupleÚ	to_ntupler   r"   r   r   r   r   Ú<module>   s    
	