Ë
    éÓ^jD  ã                   ót   — d Z ddlmZ ddlZd„ Z ed«      Z ed«      Z ed«      Z ed«      Z	eZ
dd	„Zd
„ Zy)zI Layer/Module Helpers

Hacked together by / Copyright 2020 Ross Wightman
é    )ÚrepeatNc                 ó   ‡ — ˆ fd„}|S )a<  Return a function that converts input to an n-tuple.

    Scalar values are repeated n times, while iterables are converted to tuples.
    Strings are treated as scalars to avoid character-level splitting.

    Args:
        n: Target tuple length.

    Returns:
        Function that converts input to n-tuple.
    c                 ó¬   •— t        | t        j                  j                  «      rt        | t        «      st        | «      S t        t        | ‰«      «      S )N)Ú
isinstanceÚcollectionsÚabcÚIterableÚstrÚtupler   )ÚxÚns    €ú^/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/timm/layers/helpers.pyÚparsez_ntuple.<locals>.parse   s:   ø€ Ü�aœŸ™×1Ñ1Ô2¼:ÀaÌÔ;MÜ˜“8ˆOÜ”V˜A˜q“\Ó"Ð"ó    © )r   r   s   ` r   Ú_ntupler   
   s   ø€ ô#ð €Lr   é   é   é   é   c                 ón   — |xs |}t        |t        | |dz  z   «      |z  |z  «      }||| z  k  r||z  }|S )aá  Adjust value to be divisible by a divisor, typically for channel counts.

    Rounds to the nearest multiple of divisor while ensuring the result doesn't
    fall below min_value or decrease by more than (1 - round_limit).

    Args:
        v: Value to adjust.
        divisor: Target divisor.
        min_value: Minimum acceptable value.
        round_limit: Prevent decrease beyond this fraction of original value.

    Returns:
        Adjusted value divisible by divisor.
    r   )ÚmaxÚint)ÚvÚdivisorÚ	min_valueÚround_limitÚnew_vs        r   Úmake_divisibler   $   sL   € ð Ò$˜W€IÜ�	œ3˜q 7¨Q¡;™Ó/°7Ñ:¸WÑDÓE€Eàˆ{˜Q‰ÒØ�ÑˆØ€Lr   c                 ó”   — t        | t        t        f«      s| f} nt        | «      } |t        | «      z
  }|dk  r| d| S | | d   f|z  z   S )a&  Pad a tuple to length n by repeating the last value.

    If input is shorter than n, extends by repeating the last element.
    If input is longer than n, truncates to n.

    Args:
        x: Input value, tuple, or list.
        n: Target length.

    Returns:
        Tuple of length n.
    r   Néÿÿÿÿ)r   r   ÚlistÚlen)r   r   Úpad_ns      r   Úextend_tupler%   ;   sW   € ô �aœ%¤˜Ô'ØˆD‰ä�!‹HˆØ”�A“‰J€EØ�‚zØ��!ˆuˆØ��"‘ˆx˜%ÑÑÐr   )é   NgÍÌÌÌÌÌì?)Ú__doc__Ú	itertoolsr   Úcollections.abcr   r   Ú	to_1tupleÚ	to_2tupleÚ	to_3tupleÚ	to_4tupleÚ	to_ntupler   r%   r   r   r   ú<module>r/      sL   ðñõ Û òñ& �A‹J€	Ù�A‹J€	Ù�A‹J€	Ù�A‹J€	Ø€	óó. r   