
    RЦi                         S SK r S SK Jr   S SKJrJr  SrSS	KJr  \ " S
 S\R                  5      5       r
g! \ a    Sr SS jrS r N4f = f)    N)nn)inplace_abninplace_abn_syncTFc
                     [        S5      e)Nz`Please install InplaceABN:'pip install git+https://github.com/mapillary/inplace_abn.git@v1.0.12')ImportError)
xweightbiasrunning_meanrunning_vartrainingmomentumeps
activationactivation_params
             V/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/timm/layers/inplace_abn.pyr   r   
   s    np 	p    c                      [        S0 U D6  g )N )r   )kwargss    r   r   r      s    fr      )register_notrace_modulec                   J   ^  \ rS rSrSr       SU 4S jjrS rS rSrU =r	$ )
InplaceAbn   a`  Activated Batch Normalization

This gathers a BatchNorm and an activation function in a single module

Parameters
----------
num_features : int
    Number of feature channels in the input and output.
eps : float
    Small constant to prevent numerical issues.
momentum : float
    Momentum factor applied to compute running statistics.
affine : bool
    If `True` apply learned scale and shift transformation after normalization.
act_layer : str or nn.Module type
    Name or type of the activation functions, one of: `leaky_relu`, `elu`
act_param : float
    Negative slope for the `leaky_relu` activation.
c	                   > [         T	U ]  5         Xl        X@l        X l        X0l        U(       a  [        U[        5      (       a  US;   d   eU(       a  UOSU l        OsU[        R                  :X  a  SU l        OWU[        R                  :X  a  SU l        O;Ub  U[        R                  :X  a  SU l        O SUR                   S35       eSU l        Xpl        U R                  (       a_  [        R                  " [         R"                  " U5      5      U l        [        R                  " [         R&                  " U5      5      U l        O$U R+                  SS 5        U R+                  SS 5        U R-                  S	[         R&                  " U5      5        U R-                  S
[         R"                  " U5      5        U R/                  5         g )N)
leaky_relueluidentity r   r   r   zInvalid act layer z	 for IABNr	   r
   r   r   )super__init__num_featuresaffiner   r   
isinstancestract_namer   ELU	LeakyReLUIdentity__name__	act_param	Parametertorchonesr	   zerosr
   register_parameterregister_bufferreset_parameters)
selfr#   r   r   r$   	apply_act	act_layerr,   
drop_layer	__class__s
            r   r"   InplaceAbn.__init__+   sM    	( )S)) $IIII-6	J &$)DM",,.$0DM&)r{{*B$.DMT$6y7I7I6J)"TT5&DM";;,,uzz,'?@DKU[[%>?DI##Hd3##FD1^U[[-FG]EJJ|,DEr   c                 x   [         R                  R                  U R                  S5        [         R                  R                  U R                  S5        U R
                  (       aU  [         R                  R                  U R                  S5        [         R                  R                  U R                  S5        g g )Nr   r   )r   init	constant_r   r   r$   r	   r
   )r4   s    r   r3   InplaceAbn.reset_parametersV   sr    
$++Q/
$**A.;;GGdkk1-GGdii+ r   c                    [        XR                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  U R                  5
      n[        U[        5      (       a  US   nU$ )Nr   )r   r	   r
   r   r   r   r   r   r'   r,   r%   tuple)r4   r   outputs      r   forwardInplaceAbn.forward]   sf    {{DIIt'8'8$:J:JMM4==$((DMM4>>S fe$$AYFr   )r'   r,   r$   r
   r   r   r#   r	   )h㈵>皙?TTr   {Gz?N)
r+   
__module____qualname____firstlineno____doc__r"   r3   rA   __static_attributes____classcell__)r8   s   @r   r   r      s4    . ") V, r   r   )TrD   rC   r   rE   )r.   r   inplace_abn.functionsr   r   has_iabnr   _fxr   Moduler   r   r   r   <module>rP      sg     CH ) M M M  	H gkp
	s   
7 A
A