Ë
    ÛÓ^jÇj  ã                  óî  — d dl mZ d dlmZ d dlmZ ddlmZ ddlm	Z	 ddl
mZmZmZmZ dd	lmZ dd
lmZ  e«       r:d dlZej(                  j+                  e«      Zej(                  j+                  e«      Z ej,                  e«      Z	 	 d"	 	 	 	 	 	 	 	 	 d#d„Z	 	 	 	 	 	 	 	 	 	 d$d„Zd%d„Zd%d„Zd„ Zd„ Z e«       rYej>                  jA                  dedd¬«       ej>                  jC                  de«       ej>                  jE                  dee¬«       d&d„Z#	 	 	 	 	 	 	 	 d%d„Z$	 	 d"	 	 	 	 	 	 	 	 	 	 	 d'd„Z%	 	 	 	 	 	 	 	 	 	 d$d„Z& G d„ de	«      Z' e'«       Z(d(d„Z)	 d)e(ddddd œ	 	 	 	 	 	 	 	 	 	 	 	 	 d*d!„Z*y)+é    )Úannotations)ÚCallable)Úwrapsé   )Úlogging)ÚGeneralInterface)Úis_torch_availableÚis_torch_greater_or_equalÚis_torch_less_or_equalÚis_torchdynamo_compilingé   )Údeepgemm_bf16_experts_forward)Úsonicmoe_experts_forwardNFc                ó  — |r5t        j                  | j                  d«      |«      j                  d«      }n4t        j                  || j                  d«      «      j                  d«      }|�|j	                  |«       |S )a¶  Batched linear layer supporting optional bias and transposed weights.

    Args:
        input (`torch.Tensor`):
            Input tensor of shape (batch_size, input_dim).
        weight (`torch.Tensor`):
            Weight tensor of shape (batch_size, output_dim, input_dim) if transposed is `False`,
            else of shape (batch_size, input_dim, output_dim).
        bias (`torch.Tensor`, *optional*):
            Bias tensor of shape (batch_size, output_dim). Default is `None`.
        is_transposed (`bool`, *optional*, defaults to `False`):
            Whether the weight tensor is transposed.
    Returns:
        `torch.Tensor`: Output tensor of shape (batch_size, output_dim).
    r   éÿÿÿÿ)ÚtorchÚbmmÚ	unsqueezeÚsqueezeÚadd_)ÚinputÚweightÚbiasÚis_transposedÚouts        úh/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/integrations/moe.pyÚ_batched_linearr   T   sg   € ñ* ä�i‰i˜Ÿ™¨Ó*¨FÓ3×;Ñ;¸AÓ>‰ô �i‰i˜ §¡°Ó 3Ó4×<Ñ<¸RÓ@ˆàÐØ�‰�Œà€Jó    c                ó˜  — |j                  d«      }|j                  d«      }|j                  d«      }|j                  |d¬«      }|j                  d«      }|j                  d«      }	|	j                  d| j                  dz
  «      }	| j
                  r-| j                  |	   }
| j                  r| j                  |	   nd }n,| j                  |	   }
| j                  r| j                  |	   nd }t        ||
|| j                  ¬«      }| j
                  r| j                  |«      }n| j                  |«      }| j                  |	   }
| j                  r| j                   |	   nd }t        ||
|| j                  ¬«      }||j#                  d«      z  }|j%                  |||«      j'                  d¬«      }|j)                  |j*                  «      S )Nr   r   ©Údimr   ©r   r   )ÚsizeÚrepeat_interleaveÚreshapeÚclampÚnum_expertsÚhas_gateÚgate_up_projÚhas_biasÚgate_up_proj_biasÚup_projÚup_proj_biasr   r   Ú_apply_gateÚact_fnÚ	down_projÚdown_proj_biasr   ÚviewÚsumÚtoÚdtype)ÚselfÚhidden_statesÚtop_k_indexÚtop_k_weightsÚ	num_top_kÚ
num_tokensÚ
hidden_dimÚselected_hidden_statesÚsample_weightsÚ
expert_idsÚselected_weightsÚselected_biasesÚproj_outÚweighted_outÚfinal_hidden_statess                  r   Úbatched_mm_experts_forwardrE   v   sÄ  € ð × Ñ  Ó$€IØ×#Ñ# AÓ&€JØ×#Ñ# BÓ'€Jð +×<Ñ<¸YÈAÐ<ÓNÐØ"×*Ñ*¨2Ó.€NØ×$Ñ$ RÓ(€Jð ×!Ñ! ! T×%5Ñ%5¸Ñ%9Ó:€Jð ‡}‚}Ø×,Ñ,¨ZÑ8ÐØ@DÇÂ˜$×0Ñ0°Ò<ÐSW‰àŸ<™<¨
Ñ3ÐØ;?¿=º=˜$×+Ñ+¨JÒ7Èdˆô ØÐ 0°ÐVZ×VhÑVhô€Hð
 ‡}‚}à×#Ñ# HÓ-‰ð —;‘;˜xÓ(ˆð —~‘~ jÑ1ÐØ9=¿º�d×)Ñ)¨*Ò5ÈD€Oô ØÐ"¨È×HZÑHZô€Hð
 ˜n×6Ñ6°rÓ:Ñ:€Lð '×+Ñ+¨J¸	À:ÓN×RÑRÐWXÐRÓYÐà×!Ñ! -×"5Ñ"5Ó6Ð6r   c                ó4  — t        j                  | j                  d«      |j                  d«      | j                  | j                  ¬«      }d}t        |j                  «       «      D ].  \  }}||k(  rŒt        j                  | || ||   ||| ¬«       |}Œ0 |S )a(  
    Fallback grouped matrix multiplication used when `torch.nn.functional.grouped_mm` and `torch._grouped_mm`
    are unavailable or incompatible with `torch.compile` (e.g. non-bfloat16 weights).

    Args:
        input (`torch.Tensor`): Input of shape (S, input_dim), sorted by expert id.
        weight (`torch.Tensor`): Expert weights of shape (num_experts, input_dim, output_dim).
        offs (`torch.Tensor`): Cumulative token counts per expert of shape (num_experts,).
    Returns:
        `torch.Tensor`: Output of shape (S, output_dim).
    r   r   ©Údevicer5   ©r   )r   Úzerosr#   rH   r5   Ú	enumerateÚtolistÚmm)r   r   ÚoffsÚoutputÚstartÚiÚends          r   Ú_grouped_mm_fallbackrS   ¹   s�   € ô �[‰[˜Ÿ™ A›¨¯©°A«¸u¿|¹|ÐSX×S^ÑS^Ô_€Fà€Eô ˜DŸK™K›MÓ*ò ‰ˆˆ3Ø�CŠ<ØÜ�‰��u˜SÐ! 6¨!¡9°&¸¸sÐ2CÕDØ‰ð	ð €Mr   c                óp  — | j                  «       dk(  sJ dt        | j                  «      › �«       ‚|j                  «       dk(  sJ dt        |j                  «      › �«       ‚|j                  «       dk(  sJ dt        |j                  «      › �«       ‚|j                  d«      |j                  d«      k(  s+J d|j                  d«      › d	|j                  d«      › �«       ‚| j                  d«      |j                  d«      k(  s+J d
| j                  d«      › d|j                  d«      › �«       ‚|j                  t
        j                  t
        j                  fv sJ d|j                  › �«       ‚t        j                  | j                  d«      |j                  d«      | j                  | j                  ¬«      S )zRShape/dtype inference stub for `_grouped_mm_fallback` required by `torch.compile`.r   z+input must be 2D (S, input_dim), got shape é   zBweight must be 3D (num_experts, input_dim, output_dim), got shape r   z*offs must be 1D (num_experts,), got shape r   zoffs length z must match number of experts zinput_dim mismatch: input has z, weight has z$offs must be an integer tensor, got rG   )
r!   ÚtupleÚshaper#   r5   r   Úint32Úint64ÚemptyrH   ©r   r   rN   s      r   Ú_grouped_mm_fallback_faker\   Ó   s�  € à�9‰9‹;˜!ÒÐ_ÐJÌ5ÐQV×Q\ÑQ\ÓK]ÐJ^Ð_Ó_ÐØ�:‰:‹<˜1Òð Ø
LÌUÐSY×S_ÑS_ÓM`ÐLaÐbóÐð �8‰8‹:˜Š?Ð\ÐHÌÈtÏzÉzÓIZÐH[Ð\Ó\ˆ?Ø�9‰9�Q‹<˜6Ÿ;™; q›>Ò)Ðv¨\¸$¿)¹)ÀA»,¸ÐGeÐfl×fqÑfqÐrsÓftÐeuÐ+vÓvÐ)Ø�:‰:�a‹=˜FŸK™K¨›NÒ*ð Ø
(¨¯©°A«¨°}ÀVÇ[Á[ÐQRÃ^ÐDTÐUóÐ*ð �:‰:œ%Ÿ+™+¤u§{¡{Ð3Ñ3ÐhÐ7[Ð\`×\fÑ\fÐ[gÐ5hÓhÐ3Ü�;‰;�u—z‘z !“} f§k¡k°!£n¸U¿\¹\ÐQV×Q\ÑQ\Ô]Ð]r   c                óH   — | j                  |d   |d   «       |d   | _        y)zjSaves input and weight for backward; offs is stored directly as it is a non-differentiable integer tensor.r   r   r   N)Úsave_for_backwardrN   )ÚctxÚinputsrO   s      r   Ú"_grouped_mm_fallback_setup_contextra   â   s%   € à×Ñ˜& ™) V¨A¡YÔ/Ø�a‰y€C…Hr   c                ó”  — | j                   \  }}t        j                  |«      }t        j                  |«      }d}t        | j                  j                  «       «      D ]c  \  }}||k(  rŒt        j                  ||| ||   j                  ||| ¬«       t        j                  ||| j                  ||| ||   ¬«       |}Œe ||dfS )zuBackward pass for `_grouped_mm_fallback`. Computes grad_input and grad_weight per expert group; offs has no gradient.r   rI   N)Úsaved_tensorsr   Ú
zeros_likerK   rN   rL   rM   ÚT)	r_   Úgrad_outputr   r   Ú
grad_inputÚgrad_weightrP   rQ   rR   s	            r   Ú_grouped_mm_fallback_backwardri   è   sÇ   € à×%Ñ%�M€Eˆ6Ü×!Ñ! %Ó(€JÜ×"Ñ" 6Ó*€Kà€Eô ˜CŸH™HŸO™OÓ-Ó.ò ‰ˆˆ3Ø�CŠ<ØÜ�‰�˜U 3Ð'¨°©¯©¸*ÀUÈ3Ð:OÕPÜ�‰��u˜SÐ!×#Ñ# [°°sÐ%;ÀÈQÁÕPØ‰ðð �{ DÐ(Ð(r   z!transformers::grouped_mm_fallback© z4(Tensor input, Tensor weight, Tensor offs) -> Tensor)Úmutates_argsÚschema)Úsetup_contextc                ól  — t        «       r|j                  t        j                  k7  sx|j                  j
                  dk(  r9t        dd¬«      r,|j                  «       dz  dk7  s<| j                  «       dz  dk7  s&|j                  j
                  dk(  rt        dd¬«      ry|j                  j
                  d	k(  rÆt        t        j                  j                  d
«      r,t        j                  j                  |j                  «      dk\  S t        t        d«      ret        dd¬«      r,t        j                  j                  |j                  «      dk\  S t        j                  j                  |j                  «      dk\  S yt        t        j                  j                  d
«      xs t        t        d«      S )a  
    Check if torch.nn.functional.grouped_mm or torch._grouped_mm can be used based on availability and compatibility with torch.compile.

    Args:
        input (`torch.Tensor`):
            Input tensor of shape (S, input_dim).
        weight (`torch.Tensor`):
            Weight tensor of shape (num_experts, input_dim, output_dim).
        offs (`torch.Tensor`):
            Offsets tensor indicating the boundaries of each group in the input tensor.
    Returns:
        `bool`: True if grouped_mm can be used, False otherwise.
    Úcpuz2.10.0T)Ú
accept_devé   r   z2.8.0FÚcudaÚ
grouped_mm)é   r   Ú_grouped_mmz2.9)é	   r   )r   r5   r   Úbfloat16rH   Útyper   Údata_ptrÚhasattrÚnnÚ
functionalrr   Úget_device_capabilityr
   r[   s      r   Ú_can_use_grouped_mmr~   
  s9  € ô  
"Ô	#¨¯©¼¿¹Ò(FØ�=‰=×Ñ Ò&Ü" 8¸Õ=Ø�_‰_Ó Ñ# qÒ(¨E¯N©NÓ,<¸rÑ,AÀQÒ,FØ�=‰=×Ñ Ò&Ü" 7°tÕ<ð ð
 ‡}�}×Ñ˜VÒ#Ü”5—8‘8×&Ñ&¨Ô5Ü—:‘:×3Ñ3°F·M±MÓBÀfÑLÐLÜ”5˜-Ô(Ü(¨¸4Õ@Ü—z‘z×7Ñ7¸¿¹ÓFÈ&ÑPÐPä—z‘z×7Ñ7¸¿¹ÓFÈ&ÑPÐPàä”5—8‘8×&Ñ&¨Ó5ÒV¼ÄÈÓ9VÐVr   c                óÈ  — t        | ||«      rªt        t        j                  j                  d«      rEt        j                  j                  j                  | j                  |j                  «      ||¬«      S t        t        d«      r1t        j                  | j                  |j                  «      ||¬«      S t        j                  j                  j                  | ||¬«      S )a  Grouped matrix multiplication dispatcher that uses torch.nn.functional.grouped_mm if available, else falls back to torch._grouped_mm.

    Args:
        input (`torch.Tensor`):
            Input tensor of shape (S, input_dim).
        weight (`torch.Tensor`):
            Weight tensor of shape (num_experts, input_dim, output_dim).
        offs (`torch.Tensor`):
            Offsets tensor indicating the boundaries of each group in the input tensor.
    Returns:
        `torch.Tensor`: Output tensor of shape (S, output_dim).
    rs   ©rN   ru   )r~   rz   r   r{   r|   rs   r4   r5   ru   ÚopsÚtransformersÚgrouped_mm_fallbackr[   s      r   ru   ru   :  s¤   € ô$ ˜5 &¨$Ô/ô
 ”5—8‘8×&Ñ&¨Ô5Ü—8‘8×&Ñ&×1Ñ1°%·(±(¸6¿<¹<Ó2HÈ&ÐW[Ð1Ó\Ð\Ü”U˜MÔ*Ü×$Ñ$ U§X¡X¨f¯l©lÓ%;¸VÈ$ÔOÐOä�9‰9×!Ñ!×5Ñ5°e¸VÈ$Ð5ÓOÐOr   c                óŠ   — |rt        | ||¬«      }nt        | |j                  dd«      |¬«      }|�|j                  |«       |S )a  Grouped linear layer supporting optional bias and transposed weights.

    Args:
        input (`torch.Tensor`):
            Input tensor of shape (S, input_dim).
        weight (`torch.Tensor`):
            Weight tensor of shape (num_experts, input_dim, output_dim) if `is_transposed`,
            else of shape (num_experts, output_dim, input_dim).
        offs (`torch.Tensor`):
            Offsets tensor indicating the boundaries of each group in the input tensor.
        bias (`torch.Tensor`, *optional*):
            Bias tensor of shape (num_experts, output_dim). Default is `None`.
        is_transposed (`bool`, *optional*, defaults to `False`):
            Whether the weight tensor is transposed.
    Returns:
        `torch.Tensor`: Output tensor of shape (S, output_dim).
    r€   éþÿÿÿr   )ru   Ú	transposer   )r   r   rN   r   r   r   s         r   Ú_grouped_linearr‡   Y  sH   € ñ0 ä˜% ¨dÔ3‰ô ˜% ×!1Ñ!1°"°bÓ!9ÀÔEˆàÐà�‰�Œà€Jr   c                óØ  — |j                   }|j                  d«      }|j                  d«      }|j                  d«      }|j                  d«      }|j                  d«      }	t        j                  |	«      \  }
}|||z     }||   }|j
                  dv r|
j                  «       n|
j                  «       }t        j                  || j                  d| j                  dz
  ¬«      }t        j                  |dt        j                  ¬«      }|
| j                  k\  j                  d«      }|
j                  | j                  dz
  ¬«       | j                  r*| j                  }| j                   r| j"                  |
   nd }n)| j$                  }| j                   r| j&                  |
   nd }|j)                  |d«       t+        ||||| j,                  ¬	«      }| j                  r| j/                  |«      }n| j1                  |«      }| j2                  }| j                   r| j4                  |
   nd }t+        ||||| j,                  ¬	«      }||j                  d«      z  }|j)                  |d«       t        j6                  |«      }t        j8                  |j                  d«      |¬
«      ||<   ||   }|j;                  |||«      j=                  d¬«      }|j?                  |j@                  «      S )Nr   r   )ro   Úmpsr   )ÚbinsÚminÚmax)r!   r5   )rŒ   g        r"   )rH   r    )!rH   r#   r%   r   Úsortrx   ÚfloatÚintÚhistcr'   ÚcumsumrX   r   Úclamp_r(   r)   r*   r+   r,   r-   Úmasked_fill_r‡   r   r.   r/   r0   r1   Ú
empty_likeÚaranger2   r3   r4   r5   )r6   r7   r8   r9   rH   r:   r;   r<   r>   r?   Úexpert_ids_gÚpermÚselected_hidden_states_gÚsample_weights_gÚhistc_inputÚtokens_per_expertÚoffsetsÚsentinel_maskr@   rA   rB   rC   Úinv_permrD   s                           r   Úgrouped_mm_experts_forwardrŸ     s¼  € ð ×!Ñ!€FØ× Ñ  Ó$€IØ×#Ñ# AÓ&€JØ×#Ñ# BÓ'€Jð #×*Ñ*¨2Ó.€NØ×$Ñ$ RÓ(€Jô Ÿ™ JÓ/Ñ€L�$Ø,¨T°YÑ->Ñ?ÐØ% dÑ+Ðð +1¯+©+¸Ñ*G�,×$Ñ$Ô&È\×M]ÑM]ÓM_€KÜŸ™ K°d×6FÑ6FÈAÐSW×ScÑScÐfgÑSgÔhÐÜ�l‰lÐ,°!¼5¿;¹;ÔG€Gð" " T×%5Ñ%5Ñ5×@Ñ@ÀÓD€MØ×Ñ˜D×,Ñ,¨qÑ0ÐÔ1ð ‡}‚}Ø×,Ñ,ÐØBFÇ-Â-˜$×0Ñ0°Ò>ÐUY‰àŸ<™<ÐØ=A¿]º]˜$×+Ñ+¨LÒ9ÐPTˆð ×)Ñ)¨-¸Ô=ô Ø Ð"2°GÀ/Ðae×asÑasô€Hð
 ‡}‚}à×#Ñ# HÓ-‰ð —;‘;˜xÓ(ˆð —~‘~ÐØ;?¿=º=�d×)Ñ)¨,Ò7Èd€Oô ØÐ" G°/ÐQU×QcÑQcô€Hð
 Ð.×8Ñ8¸Ó<Ñ<€Lð ×Ñ˜m¨SÔ1ô ×Ñ Ó%€HÜ—\‘\ $§)¡)¨A£,°vÔ>€HˆT�NØ Ñ)€Lð '×+Ñ+¨J¸	À:ÓN×RÑRÐWXÐRÓYÐà×!Ñ! -×"5Ñ"5Ó6Ð6r   c                  ó2   ‡ — e Zd ZdZeeeedœZdˆ fd„Z	ˆ xZ
S )ÚExpertsInterfacez;Interface for registering custom experts forward functions.)ÚdeepgemmÚ
batched_mmrs   Úsonicmoec                ó„   •— |€t         j                  d«       n|dk7  r|| vrt        d|› d�«      ‚t        ‰| �  ||«      S )zfReturn the requested `experts_implementation`. Also strictly check its validity, and raise if invalid.a
  You tried to access the `ExpertsInterface` with a `config._experts_implementation` set to `None`. This is expected if you use an Expert Module as a standalone Module. If this is not the case, something went wrong with the dispatch of `config._experts_implementation`Úeagerú`zL` is not a valid experts implementation registered in the `ExpertsInterface`)ÚloggerÚwarning_onceÚKeyErrorÚsuperÚget)r6   Úexperts_implementationÚdefaultÚ	__class__s      €r   Úget_interfacezExpertsInterface.get_interfaceñ  s`   ø€ à!Ð)Ü×ÑðNõð
 $ wÒ.Ð3IÐQUÑ3UÜØÐ*Ð+Ð+wÐxóð ô ‰w‰{Ð1°7Ó;Ð;r   )r­   Ústrr®   r   Úreturnr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rE   rŸ   r   Ú_global_mappingr°   Ú__classcell__)r¯   s   @r   r¡   r¡   ç  s%   ø„ ÙEð 2Ø0Ø0Ø,ñ	€O÷<ñ <r   r¡   c                óV   — |j                  dd¬«      \  }}| j                  |«      |z  S )a›  
    Default gating mechanism: splits the gate_up_out into gate and up parts,
    applies the activation function to the gate part, and multiplies it with the up part.
    Args:
        gate_up_out (`torch.Tensor`):
            The output tensor from the gate and up projection of shape (S, 2 * intermediate_dim).
    Returns:
        `torch.Tensor`: The gated output tensor of shape (S, intermediate_dim).
    r   r   r    )Úchunkr/   )r6   Úgate_up_outÚgateÚups       r   Ú_default_apply_gater¾     s1   € ð × Ñ  ¨Ð Ó+�H€Dˆ"Ø�;‰;�tÓ˜rÑ!Ð!r   T)Úexperts_interfaceÚis_concatenatedr   r*   r(   c               ó8   ‡‡‡‡‡— dˆˆˆˆˆfd„}| � || «      S |S )a¤  Decorator to modify experts class to support different experts implementations.

    Args:
        experts_class (`type[torch.nn.Module]`, *optional*):
            The experts class to modify. If not provided, returns a decorator that can be applied to the class.
        experts_interface (`ExpertsInterface`, *optional*, defaults to `ALL_EXPERTS_FUNCTIONS`):
            The experts interface to use for dispatching the forward method.
        is_concatenated (`bool`, *optional*, defaults to `True`):
            Whether the expert weights are stored in concatenated layout [gate;up]
            or interleaved layout [gate0, up0, gate1, up1, ...].
        is_transposed (`bool`, *optional*, defaults to `False`):
            Whether the expert weights are stored in transposed format.
        has_bias (`bool`, *optional*, defaults to `False`):
            Whether the expert layers include bias terms or not.
        has_gate (`bool`, *optional*, defaults to `True`):
            Whether the experts use a gating mechanism or not.
            Whether it has gate_up_proj weights or just up_proj weights.

    Returns:
        `type[torch.nn.Module]`: The modified experts class.
    c                óÜ   •‡‡— | j                   Š| j                  Št        ‰«      ˆˆˆˆ	ˆfd„«       }t        ‰«      ˆˆfd„«       }t        | d«      st        | _        || _         || _        | S )Nc                óf   •—  ‰| |g|¢­i |¤Ž || _         ‰| _        ‰| _        ‰| _        ‰| _        y ©N)Úconfigr(   r*   r   rÀ   )	r6   rÅ   ÚargsÚkwargsr*   r(   rÀ   r   Úoriginal_inits	       €€€€€r   Ú__init__z=use_experts_implementation.<locals>.wrapper.<locals>.__init__4  s<   ø€ á˜$ Ð8¨Ò8°Ò8Ø ˆDŒKØ$ˆDŒMØ$ˆDŒMØ!.ˆDÔØ#2ˆDÕ r   c                óh   •— ‰j                  | j                  j                  ‰«      } || g|¢­i |¤ŽS rÄ   )r°   rÅ   Ú_experts_implementation)r6   rÆ   rÇ   Úexperts_forwardr¿   Úoriginal_forwards       €€r   Úforwardz<use_experts_implementation.<locals>.wrapper.<locals>.forward=  s5   ø€ à/×=Ñ=¸d¿k¹k×>aÑ>aÐcsÓtˆOÙ" 4Ð9¨$Ò9°&Ñ9Ð9r   r.   )rÉ   rÎ   r   rz   r¾   r.   )
Úexperts_classrÉ   rÎ   rÍ   rÈ   r¿   r*   r(   rÀ   r   s
      @@€€€€€r   Úwrapperz+use_experts_implementation.<locals>.wrapper0  su   ú€ Ø%×.Ñ.ˆØ(×0Ñ0Ðä	ˆ}Ó	÷	3ó 
ð	3ô 
ÐÓ	 ô	:ó 
!ð	:ô �} mÔ4Ü(;ˆMÔ%à!)ˆÔØ 'ˆÔØÐr   )rÏ   útype[torch.nn.Module]r²   rÑ   rj   )rÏ   r¿   rÀ   r   r*   r(   rÐ   s    ````` r   Úuse_experts_implementationrÒ     s%   ü€ ÷>ñ ð2 Ð Ù�}Ó%Ð%à€Nr   )NF)
r   útorch.Tensorr   rÓ   r   útorch.Tensor | Noner   Úboolr²   rÓ   )
r6   ztorch.nn.Moduler7   rÓ   r8   rÓ   r9   rÓ   r²   rÓ   )r   rÓ   r   rÓ   rN   rÓ   r²   rÓ   )r   rÓ   r   rÓ   rN   rÓ   r²   rÕ   )r   rÓ   r   rÓ   rN   rÓ   r   rÔ   r   rÕ   r²   rÓ   )r»   rÓ   r²   rÓ   rÄ   )rÏ   ztype[torch.nn.Module] | Noner¿   r¡   rÀ   rÕ   r   rÕ   r*   rÕ   r(   rÕ   r²   rÑ   )+Ú
__future__r   Úcollections.abcr   Ú	functoolsr   Úutilsr   Úutils.genericr   Úutils.import_utilsr	   r
   r   r   r¢   r   r¤   r   r   Ú_dynamoÚassume_constant_resultÚ
get_loggerr³   r¨   r   rE   rS   r\   ra   ri   ÚlibraryÚ	custom_opÚregister_fakeÚregister_autogradr~   ru   r‡   rŸ   r¡   ÚALL_EXPERTS_FUNCTIONSr¾   rÒ   rj   r   r   ú<module>rä      s–  ðõ #å $Ý å Ý ,÷ó õ 4Ý .ñ ÔÛð
 !&§¡× DÑ DÐE^Ó _ÐØ"Ÿ]™]×AÑAÐBXÓYÐð 
ˆ×	Ñ	˜HÓ	%€ð\ !%Øð	Øðàðð ðð ð	ð
 óðD=7Ø
ð=7àð=7ð ð=7ð  ð	=7ð
 ó=7óFó4^òò)ñ& ÔØ	‡M�M×ÑØ+ØØØEð	 ô ð 
‡M�M×ÑÐ CÐE^Ô_Ø	‡M�M×#Ñ#Ø+Ø%Ø8ð $ô ó-Wð`PØðPàðPð ðPð ó	PðF !%Øð#Øð#àð#ð ð#ð ð	#ð
 ð#ð ó#ðLe7Ø
ðe7àðe7ð ðe7ð  ð	e7ð
 óe7ôP<Ð'ô <ñ2 )Ó*Ð ó"ð 37ð;ð +@Ø ØØØñ;Ø/ð;ð (ð;ð ð	;ð
 ð;ð ð;ð ð;ð ô;r   