
    ^j	u                        d Z ddlZddlmZmZmZmZ ddlZddlm	Z	 ddl
m	c mZ ddlmZmZ ddlmZ ddlmZ  ej(                  e      Z G d d	e	j.                        Zd
eee	j.                  ef   de	j.                  dee   deej4                     deej6                     defdZ G d de      Z G d de	j.                        Z G d de      Zy)z5Knowledge distillation training tasks and components.    N)DictOptionalTupleUnion)create_modelgroup_parameters)unwrap_model   )TrainingTaskc                       e Zd ZdZ	 	 	 	 	 ddeeej                  f   dee	   de	dee   dee
j                     dee
j                     f fdZd	e
j                  d
e
j                  fdZ	 	 	 	 ddedee   deded
d f
dZ	 dd	e
j                  ded
e
j                  fdZ	 	 dd	e
j                  dee
j                     dee
j                     d
e
j                  fdZ xZS )DistillationTeacherae  Wrapper for a teacher model used in knowledge distillation.

    Creates and manages a pre-trained teacher model for knowledge distillation,
    handling model creation and normalization differences between teacher and student.

    Can be created from:
    - A model name string (creates the model internally with pretrained weights)
    - An existing nn.Module (wraps it with the necessary interface)

    Args:
        model_name_or_module: Either a model name string or an nn.Module
        num_classes: Number of output classes (required if model_name_or_module is a string)
        in_chans: Number of input channels (used if model_name_or_module is a string)
        pretrained_path: Optional path to pretrained weights (used if model_name_or_module is a string)
        device: Device to place the model on
        dtype: Model dtype (uses float32 if None)
    model_name_or_modulenum_classesin_chanspretrained_pathdevicedtypec           	         t         |           t        |t              rAt        j                  d| d       ddi}|rt        ||      |d<   t        d|||||d|}n>t        |t        j                        r|}n!t        dt        |      j                         |j                          || _        t        |      }	t!        |	d	      r9|	j"                  j%                  d
d      }
|	j"                  j%                  dd      }nd}
d}t'        j(                  |
||      j+                  dddd      }t'        j(                  |||      j+                  dddd      }| j-                  d|d       | j-                  d|d       d | _        y )NzCreating KD teacher model: ''
pretrainedT)filer   pretrained_cfg_overlay)
model_namer   r   r   r   z8model_name_or_module must be a string or nn.Module, got pretrained_cfgmean)g
ףp=
?gv/?gCl?std)gZd;O?gy&1?g?r   r   r
   mean_kdF
persistentstd_kd )super__init__
isinstancestr_loggerinfodictr   nnModule	TypeErrortype__name__evalmodelr	   hasattrr   gettorchtensorviewregister_buffer_compiled_forward_features)selfr   r   r   r   r   r   pretrained_kwargsr1   model_unwrappedr   r   r   r"   	__class__s                 a/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/timm/task/distillation.pyr%   zDistillationTeacher.__init__%   s    	*C0LL78L7MQOP!-t 4>B( +?!":;
 ! /'! $E ,bii8(EJ4PdKeKnKnJop  	


 'u-?$45"1155f>STD!0044U<QRC(D'C,,tF%@EEaQPQRc&>CCAr1aPYEBXv%@*.'    inputreturnc                 $   t        | j                  d      rt        | j                  d      s-t        d| j                  j                  j                   d      | j                  j                  |      }| j                  j                  |d      S )Nforward_featuresforward_headzModel zi does not support feature extraction. Ensure the model has 'forward_features' and 'forward_head' methods.T
pre_logits)r2   r1   
ValueErrorr<   r/   rB   rC   )r9   r?   feature_maps      r=   _forward_featuresz%DistillationTeacher._forward_features[   s    tzz#56gdjjR`>a--667 8V V  jj11%8zz&&{t&DDr>   backendmodecompile_modelcompile_featuresc                     |r(t        j                  | j                  f||d|| _        |r(t        j                  | j                  f||d|| _        | S )z;Compile teacher inference paths used by distillation tasks.rI   rJ   )r4   compiler1   rH   r8   )r9   rI   rJ   rK   rL   compile_kwargss         r=   rO   zDistillationTeacher.compiled   sa     tzz`7`Q_`DJ.3mm&&// !	/D+ r>   return_featuresc                     |r.| j                   | j                  |      S | j                  |      S | j                  |      S )aG  Forward pass through teacher model.

        Args:
            input: Input tensor (should already be normalized for teacher)
            return_features: Whether to return pooled pre-logits features instead of logits

        Returns:
            Logits or pooled pre-logits features depending on return_features flag
        )r8   rH   r1   )r9   r?   rQ   s      r=   forwardzDistillationTeacher.forwardx   sD     ..:66u==))%00::e$$r>   student_meanstudent_stdc                     |||S t        j                  || j                        r"t        j                  || j                        r|S ||z  |z   | j                  z
  | j                  z  S )ao  Normalize input to match teacher's expected normalization.

        Args:
            input: Input tensor (already normalized for student)
            student_mean: Student normalization mean buffer [1, 3, 1, 1]
            student_std: Student normalization std buffer [1, 3, 1, 1]

        Returns:
            Input tensor normalized for the teacher model
        )r4   equalr   r"   )r9   r?   rT   rU   s       r=   normalize_inputz#DistillationTeacher.normalize_input   sa      ;#6L;;|T\\2u{{;PTP[P[7\L#l2T\\AT[[PPr>   )N   NNN)inductorNTFF)NN)r/   
__module____qualname____doc__r   r'   r+   r,   r   intr4   r   r   r%   TensorrH   boolrO   rS   rX   __classcell__r<   s   @r=   r   r      se   * *.-1-1+/4/"'RYY"74/ "#4/ 	4/
 &c]4/ U\\*4/ EKK(4/lEu|| E E &"&"&%* 3-  	
 # 
. %*%<<% "% 
	%0 4826	Q<<Q #5<<0Q "%,,/	Q
 
Qr>   r   teacherstudent_modelr   r   r   r@   c                     t        | t              r| S t        |      }|j                  }|j                  }t        | |||||      S )a  Resolve teacher input to a DistillationTeacher instance.

    Args:
        teacher: Model name string, nn.Module, or DistillationTeacher
        student_model: Student model to infer num_classes/in_chans from
        pretrained_path: Optional path to teacher pretrained weights
        device: Device for teacher
        dtype: Dtype for teacher

    Returns:
        DistillationTeacher instance
    )r   r   r   r   r   r   )r&   r   r	   r   r   )rd   re   r   r   r   student_unwrappedr   r   s           r=   _resolve_teacherrh      sV    & './ %]3#//K ))H$' r>   c                       e Zd ZdZ	 	 	 	 	 	 	 	 	 ddej
                  deeej
                  ef   de	ej
                     de	e   dede	e
   de	e
   d	e
d
e	ej                     de	ej                     def fdZ	 dde	e   dd fdZ	 	 ddede	e   dej
                  fdZdej&                  dej&                  deeej&                  f   fdZ xZS )LogitDistillationTaska  Logit-based knowledge distillation task.

    Performs distillation by matching student and teacher output logits using
    KL divergence with temperature scaling.

    Loss weighting supports two modes:
    1. Independent weights: loss = task_loss_weight * task_loss + distill_loss_weight * distill_loss
    2. Complementary mode: loss = task_loss_weight * task_loss + (1 - task_loss_weight) * distill_loss
       (used when only task_loss_weight is specified)

    Args:
        student_model: Student model to train
        teacher_model: Teacher model - can be a model name string, nn.Module, or DistillationTeacher
        criterion: Task loss function (default: CrossEntropyLoss)
        teacher_pretrained_path: Path to teacher pretrained weights (used when teacher_model is a string)
        loss_type: Type of distillation loss (currently only 'kl' supported)
        distill_loss_weight: Weight for distillation loss
        task_loss_weight: Weight for task loss
        temperature: Softmax temperature for distillation (typical values: 1-4)
        device: Device for task tensors/buffers
        dtype: Dtype for task tensors/buffers
        verbose: Enable info logging

    Example:
        >>> # With model name string (num_classes/in_chans inferred from student)
        >>> task = LogitDistillationTask(
        ...     student_model=model, teacher_model='resnet50',
        ...     criterion=nn.CrossEntropyLoss(),
        ...     task_loss_weight=0.3, temperature=4.0,
        ...     device=torch.device('cuda'),
        ... )
        >>> # With raw model
        >>> task = LogitDistillationTask(
        ...     student_model=model, teacher_model=my_teacher_model,
        ...     criterion=nn.CrossEntropyLoss(),
        ...     task_loss_weight=0.3, temperature=4.0,
        ... )
    re   teacher_model	criterionteacher_pretrained_path	loss_typedistill_loss_weighttask_loss_weighttemperaturer   r   verbosec                    t         |   |	|
|       t        |||| j                  | j                        }|| _        || _        ||nt        j                         | _	        || _
        || _        |dk7  rt        d| d      t        |      }t        j                  |j                   d   | j                  | j                        j#                  dddd      }t        j                  |j                   d	   | j                  | j                        j#                  dddd      }| j%                  d
|d       | j%                  d|d       |D|| _        ||nd| _        | j*                  rt,        j/                  d| j(                   d|        n|C|| _        d|z
  | _        | j*                  rot,        j/                  d| d| j&                          nId| _        d| _        | j*                  r/t,        j/                  d| j(                   d| j&                          | j*                  rt,        j/                  d| d|        y y )Nr   r   rr   klzUnsupported loss_type 'z$'. Currently only 'kl' is supported.r   r   r
   r   r   rT   Fr    rU         ?z9LogitDistillationTask: Independent weights - task_weight=, distill_weight=z8LogitDistillationTask: Complementary mode - task_weight=z;LogitDistillationTask: Default equal weights - task_weight=z!LogitDistillationTask: loss_type=z, temperature=)r$   r%   rh   r   r   trainable_modulerd   r+   CrossEntropyLossrl   rn   rq   rF   r	   r4   r5   r   r6   r7   ro   rp   rr   r(   r)   )r9   re   rk   rl   rm   rn   ro   rp   rq   r   r   rr   rd   rg   rT   rU   r<   s                   r=   r%   zLogitDistillationTask.__init__   sb    	eWE ##KKJJ
 !.&/&;ATATAV"&6ykAefgg )7||,,V4;;**
 $q"a
	 	
 ll,,U3;;**
 $q"a
	 	
 	^\eL]KEJ *':D$8H8T$4Z]D!||##'#8#8"99JK^J_a )$4D!'*-='=D$||##3"44EdF^F^E_a (+D$$'D!||##'#8#8"99J4KcKcJdf
 <<LL3I;n[MZ r>   
device_idsr@   c                     ddl m} | j                  j                         D ]	  }d|_          || j
                  fd|i|| _        | S )a  Prepare task for distributed training.

        Wraps the student model in DistributedDataParallel (DDP) while leaving
        the frozen teacher model unwrapped.

        Args:
            device_ids: List of device IDs for DDP (e.g., [local_rank])
            **ddp_kwargs: Additional arguments passed to DistributedDataParallel

        Returns:
            self (for method chaining)
        r   DistributedDataParallelFrz   torch.nn.parallelr}   rd   
parametersrequires_gradrx   r9   rz   
ddp_kwargsDDPparams        r=   prepare_distributedz)LogitDistillationTask.prepare_distributedD  Q    " 	E\\,,. 	(E"'E	( !$D$9$9 _j _T^ _r>   rI   rJ   c                     t        j                  | j                  f||d|| _        | j                  | _         | j                  j                  d||ddd| | j                  S )z=Compile student eval/train forward and teacher logit forward.rN   TFrI   rJ   rK   rL   r#   )r4   rO   rx   
eval_modelrd   )r9   rI   rJ   rP   s       r=   rO   zLogitDistillationTask.compile]  ss     !&d.C.C rW[_ rcq r// 	
"		

 	
 $$$r>   r?   targetc                 l   | j                  |      }| j                  ||      }t        j                         5  | j                  j                  || j                  | j                        }| j	                  |j                         d      }ddd       t        j                  || j                  z  d      }t        j                  | j                  z  d      }t        j                  ||dd      | j                  d	z  z  }	| j                  |z  | j                  |	z  z   }
|
|||	d
S # 1 sw Y   xY w)a  Forward pass with logit distillation.

        Args:
            input: Input tensor [B, C, H, W]
            target: Target labels [B]

        Returns:
            Dictionary containing:
                - 'loss': Combined training loss (task + distillation)
                - 'output': Student logits (for metrics)
                - 'task_loss': Classification loss component
                - 'kd_loss': Logit distillation loss component
        FrQ   Nr   )dim	batchmeanT)	reduction
log_target   lossoutput	task_losskd_loss)rx   rl   r4   no_gradrd   rX   rT   rU   detachFlog_softmaxrq   kl_divrp   ro   )r9   r?   r   student_logitsr   input_kdteacher_logitsprob_sprob_tr   
total_losss              r=   rS   zLogitDistillationTask.forwardp  s   $ ..u5NN>6:	]]_ 	T||33E4;L;LdN^N^_H!\\(//*;U\SN	T ~0@0@@bI~0@0@@bI((66[TRVZVfVfjkVkl**Y69Q9QT[9[[
 $"	
 	
	T 	Ts   AD**D3)	NNru   NNrv   NNTNrZ   N)r/   r\   r]   r^   r+   r,   r   r'   r   r   floatr4   r   r   ra   r%   listr   rO   r`   r   rS   rb   rc   s   @r=   rj   rj      sh   %V .259!3704!$-1+/ Q99Q !bii1D!DEQ  		*	Q
 &.c]Q Q "*%Q 'uoQ Q U\\*Q EKK(Q Qj *.  
!	6 &"&%% 3-%
 
%&$
<<$
 LL$
 
c5<<	 	$
r>   rj   c                        e Zd ZdZ	 ddej
                  deej
                     f fdZd Zdde	fdZ
dej                  d	eej                  ej                  f   fd
Z xZS )"FeatureDistillationTrainableModulea  Trainable module for feature distillation.

    Wraps student model and projection layer into a single module where all
    trainable forward operations happen inside forward(). This ensures proper
    DDP wrapping when the module is used with DistributedDataParallel.
    re   
projectionc                 >    t         |           || _        || _        y)z Create trainable module wrapper for feature distillation.

        Args:
            student_model: Student model to train
            projection: Optional projection layer (Linear layer or None)
        N)r$   r%   studentr   )r9   re   r   r<   s      r=   r%   z+FeatureDistillationTrainableModule.__init__  s     	$$r>   c                     t        | j                        }t        |d      s
t               S |j	                         D ch c]  }d|z   	 c}S c c}w )Nno_weight_decaystudent.)r	   r   r2   setr   )r9   r   names      r=   r   z2FeatureDistillationTrainableModule.no_weight_decay  sD    t||,w 125L.5.E.E.GHd
T!HHHs   Acoarsec                     t        | j                        }t        |d      si S t        ||j	                  |      d      t        j                         d      fd}|S )Ngroup_matcher)r   T)reverser   )defaultc                 f    | j                  d      rj                  | t        d      d        S S )Nr   )
startswithr3   len)r   student_layer_map
task_layers    r=   _matcherzBFeatureDistillationTrainableModule.group_matcher.<locals>._matcher  s4    z*(,,T#j/2B-CZPPr>   )r	   r   r2   r   r   maxvalues)r9   r   r   r   r   r   s       @@r=   r   z0FeatureDistillationTrainableModule.group_matcher  sa    t||,w0I,Wg6K6KSY6K6Zdhi*113Q?
	
 r>   r?   r@   c                     | j                   j                  |      }| j                   j                  |      }| j                   j                  |d      }| j                  | j                  |      }||fS )a  Forward pass through student and projection.

        Args:
            input: Input tensor [B, C, H, W]

        Returns:
            Tuple of (student_logits, student_features) where features are
            optionally projected to match teacher dimension.
        TrD   )r   rB   rC   r   )r9   r?   rG   r   student_featuress        r=   rS   z*FeatureDistillationTrainableModule.forward  sl     ll33E:22;?<<44[T4R??&#/?@///r>   r   r[   )r/   r\   r]   r^   r+   r,   r   r%   r   ra   r   r4   r`   r   rS   rb   rc   s   @r=   r   r     sl     /3%99% !+%ID 0U\\ 0eELL%,,4N.O 0r>   r   c                       e Zd ZdZ	 	 	 	 	 	 	 	 	 d#dej
                  deeej
                  ef   de	ej
                     de	e   de	e
   de	e
   d	e	e   d
e	e   de	ej                     de	ej                     def fdZedej
                  defd       Z	 d$de	e   dd fdZ	 	 d%dede	e   dej
                  fdZd&de	ej
                     dede	ej
                     f fdZ	 	 d&de	ej
                     dedeeeeej0                  f   f   fdZd'defdZ	 	 	 d(de	eeeeej0                  f   f      dede	ej
                     deddf
dZd ej0                  d!ej0                  deeej0                  f   fd"Z xZS ))FeatureDistillationTaska  Feature-based knowledge distillation task.

    Performs distillation by matching student and teacher intermediate features
    (pooled pre-logits) using MSE loss. Automatically creates a projection layer
    if student and teacher feature dimensions differ.

    Loss weighting supports two modes:
    1. Independent weights: loss = task_loss_weight * task_loss + distill_loss_weight * distill_loss
    2. Complementary mode: loss = task_loss_weight * task_loss + (1 - task_loss_weight) * distill_loss
       (used when only task_loss_weight is specified)

    Args:
        student_model: Student model to train
        teacher_model: Teacher model - can be a model name string, nn.Module, or DistillationTeacher
        criterion: Task loss function (default: CrossEntropyLoss)
        teacher_pretrained_path: Path to teacher pretrained weights (used when teacher_model is a string)
        distill_loss_weight: Weight for distillation loss
        task_loss_weight: Weight for task loss
        student_feature_dim: Student pre-logits dimension (auto-detected if None)
        teacher_feature_dim: Teacher pre-logits dimension (auto-detected if None)
        device: Device for task tensors/buffers
        dtype: Dtype for task tensors/buffers
        verbose: Enable info logging

    Example:
        >>> # With model name string (num_classes/in_chans inferred from student)
        >>> task = FeatureDistillationTask(
        ...     student_model=model, teacher_model='resnet50',
        ...     criterion=nn.CrossEntropyLoss(),
        ...     distill_loss_weight=5.0, task_loss_weight=1.0,
        ...     device=torch.device('cuda'),
        ... )
    Nre   rk   rl   rm   ro   rp   student_feature_dimteacher_feature_dimr   r   rr   c                    t         |   |	|
|       t        |||| j                  | j                        }|| _        ||nt        j                         | _        |D|| _	        ||nd| _
        | j                  rt        j                  d| j                   d|        n|C|| _
        d|z
  | _	        | j                  rot        j                  d| d| j                          nId| _	        d| _
        | j                  r/t        j                  d| j                   d| j                          || j                  |      }|| j                  |j                        }d }||k7  rU| j                  rt        j                  d| d|        t        j                   ||| j                  | j                  	      }n!| j                  rt        j                  d
       t#        ||      | _        t'        |      }t)        j*                  |j,                  d   | j                  | j                  	      j/                  dddd      }t)        j*                  |j,                  d   | j                  | j                  	      j/                  dddd      }| j1                  d|d       | j1                  d|d       | j                  rt        j                  d| d|        y y )Nrt   rv   z;FeatureDistillationTask: Independent weights - task_weight=rw   z:FeatureDistillationTask: Complementary mode - task_weight=z=FeatureDistillationTask: Default equal weights - task_weight=zCreating projection layer: z -> r   z.Feature dimensions match, no projection neededr   r
   r   r   rT   Fr    rU   z%FeatureDistillationTask: student_dim=z, teacher_dim=)r$   r%   rh   r   r   rd   r+   ry   rl   ro   rp   rr   r(   r)   _detect_feature_dimr1   Linearr   rx   r	   r4   r5   r   r6   r7   )r9   re   rk   rl   rm   ro   rp   r   r   r   r   rr   rd   r   rg   rT   rU   r<   s                    r=   r%   z FeatureDistillationTask.__init__  s    	eWE ##KKJJ
 &/&;ATATAV *':D$8H8T$4Z]D!||##'#8#8"99JK^J_a )$4D!'*-='=D$||##3"44EdF^F^E_a (+D$$'D!||##'#8#8"99J4KcKcJdf &"&":":="I&"&":":7=="I 
"55||12E1FdK^J_` #68KTXT_T_gkgqgqrJ||MN B=R\ ] )7||,,V4;;**
 $q"a
	 	
 ll,,U3;;**
 $q"a
	 	
 	^\eL]KEJ<<LL23>BUAVX r>   r1   r@   c                     t        |       } t        | d      r| j                  S t        | d      r| j                  S t	        d      )z)Auto-detect feature dimension from model.head_hidden_sizenum_featureszCannot auto-detect feature dimension. Model must have 'head_hidden_size' or 'num_features' attribute, or you must specify student_feature_dim and teacher_feature_dim explicitly.)r	   r2   r   r   rF   )r1   s    r=   r   z+FeatureDistillationTask._detect_feature_dim\  sN     U#5,-)))UN+%%%R r>   rz   c                     ddl m} | j                  j                         D ]	  }d|_          || j
                  fd|i|| _        | S )a  Prepare task for distributed training.

        Wraps the trainable module (student + projection) in DistributedDataParallel
        (DDP) while leaving the frozen teacher model unwrapped.

        Args:
            device_ids: List of device IDs for DDP (e.g., [local_rank])
            **ddp_kwargs: Additional arguments passed to DistributedDataParallel

        Returns:
            self (for method chaining)
        r   r|   Frz   r~   r   s        r=   r   z+FeatureDistillationTask.prepare_distributedl  r   r>   rI   rJ   c                     t        j                  | j                  j                  f||d|}|| _        t        j                  | j                  f||d|| _         | j
                  j                  d||ddd| |S )z9Compile feature-distillation train and eval entry points.rN   FTr   r#   )r4   rO   rx   r   r   rd   )r9   rI   rJ   rP   r   s        r=   rO   zFeatureDistillationTask.compile  s     ]]4#8#8#@#@o'X\o`no
$ %!!!
!
 	!
 	 	
!		

 	
 r>   moduleemac                     t         |   ||      }|}|:t        |t              r|j                  S t        |d      s	 |S |j                  }|:|S )N)r   r   r   )r$   get_eval_modelr&   r   r   r2   r   )r9   r   r   resolvedcurrentr<   s        r=   r   z&FeatureDistillationTask.get_eval_model  sc    7)S)A!'#EF&7H- nnG ! r>   c                     ||n| j                  |      }|i S t        |      }|j                  i S d|j                  j                         iS )Nr   r   )get_trainable_moduler	   r   
state_dict)r9   r   r   	trainables       r=   get_task_statez&FeatureDistillationTask.get_task_state  s^    
 "-43L3LQT3L3U>I (	'Ii22==?@@r>   exclude_headc                     t        | j                        }t        |j                  j	                               }|r|d d }|j
                  )|j                  |j
                  j	                                |S )N)r	   rx   r   r   r   r   extend)r9   r   r   r   s       r=   get_clip_parametersz+FeatureDistillationTask.get_clip_parameters  sh     !6!67	)++6689
#CRJ+i22==?@r>   statestrictc                    |sy ||n| j                  |      }||rt        d      t        d      t        |      }|j                  d      }|y |j                  |rt        d      y |j                  j                  ||       y )Nr   z.Cannot load EMA task state before setup_ema().z2Cannot load task state without a trainable module.r   z@Checkpoint has projection task state but task has no projection.)r   )r   RuntimeErrorr	   r3   r   load_state_dict)r9   r   r   r   r   r   projection_states          r=   load_task_statez'FeatureDistillationTask.load_task_state  s     !-43L3LQT3L3U>"#STTSTT (	 99\2#'"#eff,,-=f,Mr>   r?   r   c                    | j                  |      \  }}| j                  ||      }t        j                         5  | j                  j                  || j                  | j                        }| j	                  |j                         d      }ddd       t        j                  |      }| j                  |z  | j                  |z  z   }	|	|||dS # 1 sw Y   ExY w)a  Forward pass with feature distillation.

        Args:
            input: Input tensor [B, C, H, W]
            target: Target labels [B]

        Returns:
            Dictionary containing:
                - 'loss': Combined training loss (task + distillation)
                - 'output': Student logits (for metrics)
                - 'task_loss': Classification loss component
                - 'kd_loss': Feature distillation loss component
        Tr   Nr   )rx   rl   r4   r   rd   rX   rT   rU   r   r   mse_lossrp   ro   )
r9   r?   r   r   r   r   r   teacher_featuresr   r   s
             r=   rS   zFeatureDistillationTask.forward  s    $ ,0+@+@+G((NN>6:	]]_ 	U||33E4;L;LdN^N^_H#||HOO,=t|T	U **-/?@**Y69Q9QT[9[[
 $"	
 	
	U 	Us   ACC)	NNNNNNNNTr   r   )NFr[   )TNF)r/   r\   r]   r^   r+   r,   r   r'   r   r   r   r_   r4   r   r   ra   r%   staticmethodr   r   r   rO   r   r   r`   r   r   r   rS   rb   rc   s   @r=   r   r     s    L .25937041515-1+/ `99` !bii1D!DE`  		*	`
 &.c]` "*%` 'uo` "*#` "*#` U\\*` EKK(` `D 299   " *.  
#	6 &"& 3-
 
0	Xbii%8 	d 	W_`b`i`iWj 	 +/ARYY'A A 
c4U\\)**	+	A   *.NDd3+<&=!=>?N N RYY'	N
 N 
N0!
<<!
 LL!
 
c5<<	 	!
r>   r   ) r^   loggingtypingr   r   r   r   r4   torch.nnr+   torch.nn.functional
functionalr   timm.modelsr   r   
timm.utilsr	   taskr   	getLoggerr/   r(   r,   r   r'   r   r   rh   rj   r   r   r#   r>   r=   <module>r      s    ;  / /     6 #  '

H
%OQ")) OQd"sBII'::;"yy" "#" &	"
 $" "JK
L K
\=0 =0@`
l `
r>   