Ë
    éÓ^j‡	  ã                   ó0   — d Z ddlZddlmZ  G d„ d«      Zy)z¢ Interpolation helpers for timm layers

RegularGridInterpolator from https://github.com/sbarratt/torch_interpolations
Copyright Shane Barratt, Apache 2.0 license
é    N)Úproductc                   ó   — e Zd ZdZd„ Zd„ Zy)ÚRegularGridInterpolatorzò Interpolate data defined on a rectilinear grid with even or uneven spacing.
    Produces similar results to scipy RegularGridInterpolator or interp2d
    in 'linear' mode.

    Taken from https://github.com/sbarratt/torch_interpolations
    c                 ód  — || _         || _        t        | j                   t        «      st        | j                   t        «      sJ ‚t        | j                  t
        j                  «      sJ ‚t	        | j                  j                  «      | _        t        | j                   «      | _
        t        | j                  «      | j                  k(  sJ ‚t        | j                   «      D ]L  \  }}t        |t
        j                  «      sJ ‚|j                  d   | j                  j                  |   k(  rŒLJ ‚ y )Nr   )ÚpointsÚvaluesÚ
isinstanceÚtupleÚlistÚtorchÚTensorÚshapeÚmsÚlenÚnÚ	enumerate)Úselfr   r   ÚiÚps        úb/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/timm/layers/interpolate.pyÚ__init__z RegularGridInterpolator.__init__   sÞ   € ØˆŒØˆŒä˜$Ÿ+™+¤uÔ-´¸D¿K¹KÌÔ1NÐNÐNÜ˜$Ÿ+™+¤u§|¡|Ô4Ð4Ð4ä�t—{‘{×(Ñ(Ó)ˆŒÜ�T—[‘[Ó!ˆŒä�4—7‘7‹|˜tŸv™vÒ%Ð%Ð%ä˜dŸk™kÓ*ò 	6‰DˆAˆqÜ˜a¤§¡Ô.Ð.Ð.Ø—7‘7˜1‘: §¡×!2Ñ!2°1Ñ!5Ó5Ð5Ð5ñ	6ó    c                 óz  — | j                   €J ‚| j                  €J ‚t        |«      t        | j                   «      k(  sJ ‚|d   j                  d   }|D ]  }|j                  d   |k(  rŒJ ‚ g }g }g }t	        | j                   |«      D ]Ô  \  }}t        j                  ||«      }|j                  d   dz
  |||j                  d   k\  <   |dz
  j                  d|j                  d   dz
  «      }	|||	   z
  }
||   |z
  }d|
|
dk  <   d||dk  <   |
dk(  |dk(  z  }dx|
|<   ||<   |j                  |	|f«       |j                  |
|f«       |j                  |
|z   «       ŒÖ d}t        ddg| j                  ¬«      D ]„  }t	        ||«      D ��cg c]
  \  }}||   ‘Œ }}}t	        ||«      D ��cg c]  \  }}|d|z
     ‘Œ }}}|| j                  |   t        j                  t        j                  |«      d¬«      z  z  }Œ† t        j                  t        j                  |«      d¬«      }||z  S c c}}w c c}}w )Nr   é   g        g      ð?)Úrepeat)Údim)r   r   r   r   Úzipr   Ú	bucketizeÚclampÚappendr   r   ÚprodÚstack)r   Úpoints_to_interpÚKÚxÚidxsÚdistsÚoverallsr   Ú	idx_rightÚidx_leftÚ	dist_leftÚ
dist_rightÚ	both_zeroÚ	numeratorÚindexerÚonoffÚidxÚas_sÚdistÚbs_sÚdenominators                        r   Ú__call__z RegularGridInterpolator.__call__"   sY  € Ø�{‰{Ð&Ð&Ð&Ø�{‰{Ð&Ð&Ð&äÐ#Ó$¬¨D¯K©KÓ(8Ò8Ð8Ð8Ø˜QÑ×%Ñ% aÑ(ˆØ!ò 	#ˆAØ—7‘7˜1‘: “?Ð"�?ð	#ð ˆØˆØˆÜ˜Ÿ™Ð%5Ó6ò 	4‰DˆAˆqÜŸ™¨¨1Ó-ˆIØ12·±¸±¸a±ˆI�i 1§7¡7¨1¡:Ñ-Ñ.Ø! A™×,Ñ,¨Q°·±¸±
¸Q±Ó?ˆHØ˜A˜h™K™ˆIØ˜9™¨Ñ)ˆJØ')ˆI�i !‘mÑ$Ø)+ˆJ�z A‘~Ñ&Ø" a™¨J¸!©OÑ<ˆIØ;=Ð=ˆI�iÑ  :¨iÑ#8à�K‰K˜ 9Ð-Ô.Ø�L‰L˜) ZÐ0Ô1Ø�O‰O˜I¨
Ñ2Õ3ð	4ð ˆ	Ü  1˜v¨d¯f©fÔ5ò 	5ˆGÜ14°W¸dÓ1C×D¡: 5¨#�C˜“JÐDˆDÑDÜ7:¸7ÀEÓ7J×K©¨¨t�D˜˜U™“OÐKˆDÑKØ˜Ÿ™ TÑ*Ü—
‘
œ5Ÿ;™; tÓ,°!Ô4ñ5ñ 5‰Ið	5ô
 —j‘j¤§¡¨XÓ!6¸AÔ>ˆØ˜;Ñ&Ð&ùó EùÛKs   ÆH1Æ.H7N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r6   © r   r   r   r   
   s   „ ñò6ó "'r   r   )r:   r   Ú	itertoolsr   r   r;   r   r   ú<module>r=      s   ðñó
 Ý ÷:'ò :'r   