
    ^jb                        d dl Z d dlmZ d dlmZ d dlZd dlmc mZ	 d dlmZ ddl
mZ ddlmZ ddlmZmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZmZ ddlmZmZ ddlm Z m!Z! ddl"m#Z#m$Z$ ddl%m&Z& ddl'm(Z(m)Z)m*Z* ddl+m,Z,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2  G d dejf                        Z4 ed       G d dejj                               Z6 G d dejj                        Z7 G d dejj                        Z8dejr                  d e:d!ejr                  fd"Z;	 d<d#ejj                  d$ejr                  d%ejr                  d&ejr                  d'ejr                  dz  d(e<d)e<d*e&e(   fd+Z=d, Z> ed-      d=d.       Z? G d/ d0ejj                        Z@ G d1 d2e      ZAe) G d3 d4e$             ZBe) G d5 d6eB             ZCe) G d7 d8eBe             ZD G d9 d:eeB      ZEg d;ZFy)>    N)Callable)Optional)nn   )initialization)ACT2FN)CacheDynamicCache)GenerationMixin)use_kernel_forward_from_hubuse_kernel_func_from_hub)create_causal_mask) GenericForSequenceClassificationGradientCheckpointingLayer)BaseModelOutputWithPastCausalLMOutputWithPast)ROPE_INIT_FUNCTIONSdynamic_rope_update)ALL_ATTENTION_FUNCTIONSPreTrainedModel)Unpack)TransformersKwargsauto_docstringcan_return_tuple)is_flash_attention_requestedmaybe_autocastmerge_with_config_defaults)capture_outputs   )MiniCPM3Configc            	       Z     e Zd ZdZd	dedededef fdZdej                  f fdZ	 xZ
S )
MiniCPM3ScaledWordEmbeddingz\
    This module overrides nn.Embeddings' forward by multiplying with embeddings scale.
    num_embeddingsembedding_dimpadding_idxembed_scalec                     t         |   |||       || _        | j                  dt	        j
                  |      d       y )Nr&   F
persistent)super__init__scalar_embed_scaleregister_buffertorchtensor)selfr#   r$   r%   r&   	__class__s        y/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/minicpm3/modeling_minicpm3.pyr+   z$MiniCPM3ScaledWordEmbedding.__init__3   s;    D"-]ELL,ERWX    	input_idsc                     t         |   |      | j                  j                  | j                  j
                        z  S N)r*   forwardr&   toweightdtype)r0   r4   r1   s     r2   r7   z#MiniCPM3ScaledWordEmbedding.forward8   s2    wy)D,<,<,?,?@Q@Q,RRRr3   )      ?)__name__
__module____qualname____doc__intfloatr+   r.   Tensorr7   __classcell__r1   s   @r2   r"   r"   .   sG    Ys Y3 YS Y_d Y
S S Sr3   r"   RMSNormc                   h     e Zd Zddeddf fdZdej                  dej                  fdZd Z xZ	S )	MiniCPM3RMSNormepsreturnNc                     t         |           t        j                  t	        j
                  |            | _        || _        y)z>
        MiniCPM3RMSNorm is equivalent to T5LayerNorm
        N)r*   r+   r   	Parameterr.   onesr9   variance_epsilon)r0   hidden_sizerH   r1   s      r2   r+   zMiniCPM3RMSNorm.__init__>   s1     	ll5::k#:; #r3   hidden_statesc                 "   |j                   }|j                  t        j                        }|j	                  d      j                  dd      }|t        j                  || j                  z         z  }| j                  |j                  |      z  S )N   T)keepdim)	r:   r8   r.   float32powmeanrsqrtrM   r9   )r0   rO   input_dtypevariances       r2   r7   zMiniCPM3RMSNorm.forwardF   sy    #))%((7 $$Q',,R,>%Ht?T?T4T(UU{{]--k:::r3   c                 ^    t        | j                  j                         d| j                   S )Nz, eps=)tupler9   shaperM   )r0   s    r2   
extra_reprzMiniCPM3RMSNorm.extra_reprM   s*    ))*+6$2G2G1HIIr3   )gư>)
r<   r=   r>   rA   r+   r.   rB   r7   r]   rC   rD   s   @r2   rG   rG   <   s7    $ $$ $;U\\ ;ell ;Jr3   rG   c                        e Zd ZU ej                  ed<   ddef fdZe	 	 	 ddedz  de	d   de
dz  ded	ef   fd
       Z ej                         ed               Z xZS )MiniCPM3RotaryEmbeddinginv_freqNconfigc                    t         |           |j                  | _        |j                  | _        || _        | j
                  j                  d   | _        | j                  }| j                  dk7  rt        | j                     } || j
                  |      \  }| _
        | j                  d|d       | j                  d|j                         d       y )N	rope_typedefaultr`   Fr(   original_inv_freq)r*   r+   max_position_embeddingsmax_seq_len_cachedoriginal_max_seq_lenra   rope_parametersrc   compute_default_rope_parametersr   attention_scalingr-   clone)r0   ra   devicerope_init_fnr`   r1   s        r2   r+   z MiniCPM3RotaryEmbedding.__init__T   s    "("@"@$*$B$B!44[A!%!E!E>>Y&.t~~>L+7V+L($(ZeD0(..2BuUr3   rm   ztorch.deviceseq_lenrI   ztorch.Tensorc                    | j                   d   }t        | dd      xs | j                  | j                  z  }d}d|t	        j
                  d|dt        j                        j                  |t        j                        |z  z  z  }||fS )	a  
        Computes the inverse frequencies according to the original RoPE implementation
        Args:
            config ([`~transformers.PreTrainedConfig`]):
                The model configuration.
            device (`torch.device`):
                The device to use for initialization of the inverse frequencies.
            seq_len (`int`, *optional*):
                The current sequence length. Unused for this type of RoPE.
        Returns:
            Tuple of (`torch.Tensor`, `float`), containing the inverse frequencies for the RoPE embeddings and the
            post-processing scaling factor applied to the computed cos/sin (unused in this type of RoPE).
        
rope_thetahead_dimNr;   r   rQ   r:   )rm   r:   )	ri   getattrrN   num_attention_headsr.   arangeint64r8   rA   )ra   rm   ro   basedimattention_factorr`   s          r2   rj   z7MiniCPM3RotaryEmbedding.compute_default_rope_parametersd   s    & %%l3fj$/c63E3EIcIc3c U\\!S!5;;?BB&X]XcXcBdgjjk
 )))r3   c                 N   | j                   d d d d f   j                         j                  |j                  d   dd      j	                  |j
                        }|d d d d d f   j                         }t        |j
                  j                  t              r/|j
                  j                  dk7  r|j
                  j                  nd}t        |d      5  |j                         |j                         z  j                  dd      }t        j                  ||fd	      }|j                         | j                  z  }|j                         | j                  z  }	d d d        j	                  |j                   
      	j	                  |j                   
      fS # 1 sw Y   AxY w)Nr   rR   r   mpscpuF)device_typeenabledrQ   ry   rs   )r`   rA   expandr\   r8   rm   
isinstancetypestrr   	transposer.   catcosrk   sinr:   )
r0   xposition_idsinv_freq_expandedposition_ids_expandedr~   freqsembr   r   s
             r2   r7   zMiniCPM3RotaryEmbedding.forward   sR    !MM$4-8>>@GGHZHZ[\H]_acdehhijiqiqr ,QaZ 8 > > @'1!((--'E!((--[`J`ahhmmfkUC 	5&,,.1F1L1L1NNYYZ[]^_E))UEN3C'')d444C'')d444C		5 vvAGGv$cff177f&;;;	5 	5s   BFF$r6   )NNN)r<   r=   r>   r.   rB   __annotations__r    r+   staticmethodr   r@   r[   rA   rj   no_gradr   r7   rC   rD   s   @r2   r_   r_   Q   s    llV~ V  (,+/"*%*(* t* 
~u$	%	* *: U]]_<  <r3   r_   c                   $     e Zd Z fdZd Z xZS )MiniCPM3MLPc                    t         |           || _        |j                  | _        |j                  | _        t        j                  | j                  | j                  |j                        | _        t        j                  | j                  | j                  |j                        | _	        t        j                  | j                  | j                  |j                        | _
        t        |j                     | _        y )Nbias)r*   r+   ra   rN   intermediate_sizer   Linearmlp_bias	gate_projup_proj	down_projr   
hidden_actact_fnr0   ra   r1   s     r2   r+   zMiniCPM3MLP.__init__   s    !--!'!9!94#3#3T5K5KRXRaRabyy!1!143I3IPVP_P_`4#9#94;K;KRXRaRabV../r3   c                     | j                  | j                  | j                  |            | j                  |      z        }|S r6   )r   r   r   r   )r0   r   r   s      r2   r7   zMiniCPM3MLP.forward   s6    NN4;;t~~a/@#ADLLQRO#ST	r3   )r<   r=   r>   r+   r7   rC   rD   s   @r2   r   r      s    0r3   r   rO   n_reprI   c                     | j                   \  }}}}|dk(  r| S | dddddddddf   j                  |||||      } | j                  |||z  ||      S )z
    This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
    num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
    r   N)r\   r   reshape)rO   r   batchnum_key_value_headsslenrr   s         r2   	repeat_kvr      so    
 2?1D1D.Ehz!!Qa"23::5BUW\^bdlmM  (;e(CT8TTr3   modulequerykeyvalueattention_maskscalingdropoutkwargsc                    t        || j                        }t        || j                        }	t        j                  ||j	                  dd            |z  }
||
|z   }
t
        j                  j                  |
dt        j                        j                  |j                        }
t
        j                  j                  |
|| j                        }
t        j                  |
|	      }|j	                  dd      j                         }||
fS )NrQ   r   rR   )ry   r:   )ptrainingr   )r   num_key_value_groupsr.   matmulr   r   
functionalsoftmaxrT   r8   r:   r   r   
contiguous)r   r   r   r   r   r   r   r   
key_statesvalue_statesattn_weightsattn_outputs               r2   eager_attention_forwardr      s     3 ; ;<JUF$?$?@L<<z';';Aq'ABWLL!#n4==((2U]](SVVW\WbWbcL==((6??([L,,|\:K''1-88:K$$r3   c                     | dd| j                   d   dz  f   }| d| j                   d   dz  df   }t        j                  | |fd      S )z*Rotates half the hidden dims of the input..NrR   rQ   r   )r\   r.   r   )r   x1x2s      r2   rotate_halfr      sZ    	
3"!''"+"""	#B	
3q ""	#B99rc2YB''r3   rotary_pos_embc                     |j                  |      }|j                  |      }| |z  t        |       |z  z   }||z  t        |      |z  z   }||fS )a  Applies Rotary Position Embedding to the query and key tensors.

    Args:
        q (`torch.Tensor`): The query tensor.
        k (`torch.Tensor`): The key tensor.
        cos (`torch.Tensor`): The cosine part of the rotary embedding.
        sin (`torch.Tensor`): The sine part of the rotary embedding.
        unsqueeze_dim (`int`, *optional*, defaults to 1):
            The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
            sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
            that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
            k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
            cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
            the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
    Returns:
        `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
    )	unsqueezer   )qkr   r   unsqueeze_dimq_embedk_embeds          r2   apply_rotary_pos_embr      sY    & --
&C
--
&C3w;q>C/0G3w;q>C/0GGr3   c                        e Zd ZdZddededz  f fdZ	 	 ddej                  de	ej                  ej                  f   dej                  dz  d	e
dz  d
e	ej                  ej                  dz  f   f
dZ xZS )MiniCPM3AttentionaE  
    Multi-head Latent Attention (MLA), structurally identical to `DeepseekV2Attention`.
    The only difference is the rotary convention: MiniCPM3 keeps the original cos/sin RoPE
    (`apply_rotary_pos_emb`) instead of DeepSeek-V2's complex rotary, so we inherit the
    module construction and override only `forward`.
    Nra   	layer_idxc                     t         |           || _        || _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _        |j                  | _	        |j                  | _
        |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j                  |j                  z   | _        |j                  |j                   z  | _        d| _        | j                  ?t'        j(                  | j
                  | j                  | j                  z  d      | _        nt'        j(                  | j
                  |j                  |j,                        | _        t1        |j                        | _        t'        j(                  |j                  | j                  | j                  z  d      | _        t'        j(                  | j
                  |j                  |j                  z   |j,                        | _        t1        |j                        | _        t'        j(                  |j                  | j                  | j                  | j                  z
  | j                  z   z  d      | _        t'        j(                  | j                  | j                  z  | j
                  |j,                        | _        | j                  dz  | _        y )NTFr   g      ) r*   r+   ra   r   attention_dropoutrN   ru   	num_headsrr   rf   q_lora_rankqk_rope_head_dimkv_lora_rank
v_head_dimqk_nope_head_dimqk_head_dimr   r   	is_causalr   r   q_projattention_biasq_a_projrG   q_a_layernormq_b_projkv_a_proj_with_mqakv_a_layernorm	kv_b_projo_projr   r0   ra   r   r1   s      r2   r+   zMiniCPM3Attention.__init__   sL   "!'!9!9!--33'-'E'E$!-- & 7 7"// ++ & 7 7!22V5L5LL$*$>$>&B\B\$\!#))D$4$4dnntGWGW6W^cdDKIId&6&68J8JQWQfQfgDM!01C1C!DDIIf&8&8$..4K[K[:[bghDM"$))&"9"99&&#

 .f.A.ABNNd..1F1FFXY
 iiNNT__,&&
 ''D1r3   rO   position_embeddingsr   past_key_valuesrI   c                    |j                   d d \  }}||d| j                  f}||d| j                  | j                  z   f}	| j                  | j                  |      }
n/| j                  | j                  | j                  |                  }
|
j                  |      j                  dd      }
t        j                  |
| j                  | j                  gd      \  }}| j                  |      }t        j                  || j                  | j                  gd      \  }}| j!                  | j#                  |            j                  |	      j                  dd      }t        j                  || j                  | j                  gd      \  }}|j                  |d|| j                        }|\  }}t%        ||||      \  }} |j&                  g |j                   d d d }t        j(                  ||fd      }t        j(                  ||fd      }| |j+                  ||| j,                        \  }}t/        | j0                        rH| j                  | j                  k7  r/t3        j4                  |d| j                  | j                  z
  g      }t7        j8                  | j0                  j:                  t<              } || ||||f| j>                  sdn| j@                  | jB                  d|\  }}t/        | j0                        r4| j                  | j                  k7  r|d d d d d d d | j                  f   }|jE                  ||d      jG                         }| jI                  |      }||fS )NrR   r   rQ   r   r           )r   r   )%r\   r   r   r   r   r   r   r   r   viewr   r.   splitr   r   r   r   r   r   r   r   updater   r   ra   Fpadr   get_interface_attn_implementationr   r   r   r   r   r   r   )r0   rO   r   r   r   r   
batch_size
seq_lengthquery_shape	key_shapeq_statesq_passq_rotcompressed_kvk_passk_rotr   r   r   query_statesr   attention_interfacer   r   s                           r2   r7   zMiniCPM3Attention.forward  s$    "/!4!4Sb!9
J!:r43C3CDR1F1F1XY	#{{=1H}}T%7%7m8T%UVH==-771=Ht/D/DdF[F[.\bde//>MD4E4EtG\G\3]cef 3 3F ;<AA)LVVWXZ[\${{6D4I4I4??3[acd

:q*d6K6KL&S ,E5#sCu4fll3B/44yy&%b9YYB7
&'6'='=j,X\XfXf'g$J'49I9IT__9\5543C3Cdoo3U/VWL(?(M(MKK,,.E)
 %8	%
  $}}C$2H2HLL	%
 	%
!\ (49I9IT__9\%aA/@/@&@AK!))*j"EPPRkk+.L((r3   r6   )NN)r<   r=   r>   r?   r    r@   r+   r.   rB   r[   r	   r7   rC   rD   s   @r2   r   r      s    -2~ -2#* -2f /3(,>)||>) #5<<#=>>) t+	>)
 >) 
u||U\\D00	1>)r3   r   c                       e Zd Zdedef fdZ	 	 	 	 	 ddej                  dej                  dz  dej                  dz  de	dz  d	e
dz  d
eej                  ej                  f   dz  dee   dej                  fdZ xZS )MiniCPM3DecoderLayerra   r   c                    t         |           |j                  | _        t        ||      | _        t        |      | _        t        |j                  |j                        | _	        t        |j                  |j                        | _
        |j                  t        j                  |j                        z  | _        y )N)ra   r   rH   )r*   r+   rN   r   	self_attnr   mlprG   rms_norm_epsinput_layernormpost_attention_layernormscale_depthmathsqrtnum_hidden_layersresidual_scaler   s      r2   r+   zMiniCPM3DecoderLayer.__init__a  s    !--*&INv&.v/A/AvGZGZ[(78J8JPVPcPc(d% %00499V=U=U3VVr3   NrO   r   r   r   	use_cacher   r   rI   c           
          |}| j                  |      } | j                  d||||||d|\  }}	||| j                  z  z   }|}| j                  |      }| j	                  |      }||| j                  z  z   }|S )N)rO   r   r   r   r  r    )r   r   r  r   r   )
r0   rO   r   r   r   r  r   r   residual_s
             r2   r7   zMiniCPM3DecoderLayer.forwardn  s     !,,];)4>> 
')%+ 3
 
q !=43F3F#FF 55mD/ =43F3F#FFr3   )NNNFN)r<   r=   r>   r    r@   r+   r.   rB   
LongTensorr	   boolr[   r   r   r7   rC   rD   s   @r2   r   r   `  s    W~ W# W  /304(,!&HL|| t+ &&-	
  $; #5<<#=>E +, 
r3   r   c                        e Zd ZU eed<   dZdZdgZdgZdZ	dZ
dZdZdZeedZ ej$                          fd       Z xZS )MiniCPM3PreTrainedModelra   modelTr   r   )rO   
attentionsc                     t         |   |       t        |t              r+t	        j
                  |j                  |j                         y y r6   )r*   _init_weightsr   r"   init	constant_r&   r,   )r0   r   r1   s     r2   r  z%MiniCPM3PreTrainedModel._init_weights  s:    f%f9:NN6--v/H/HI ;r3   )r<   r=   r>   r    r   base_model_prefixsupports_gradient_checkpointing_no_split_modules_skip_keys_device_placement_supports_flash_attn_supports_sdpa_supports_flex_attn_can_compile_fullgraph_supports_attention_backendr   r   _can_record_outputsr.   r   r  rC   rD   s   @r2   r  r    sp    &*#/0#4"5N!"&-'
 U]]_J Jr3   r  c                        e Zd Zdef fdZeee	 	 	 	 	 	 ddej                  dz  dej                  dz  dej                  dz  dedz  dej                  dz  d	edz  d
ee   defd                     Z xZS )MiniCPM3Modelra   c           	         t         |   |       |j                  | _        |j                  | _        t        |j                  |j                  | j                  |j                        | _        t        j                  t        |j                        D cg c]  }t        ||       c}      | _        t        |j                  |j                         | _        t%        |      | _        d| _        | j+                          y c c}w )N)r&   r   ra   F)r*   r+   pad_token_idr%   
vocab_sizer"   rN   	scale_embembed_tokensr   
ModuleListranger  r   layersrG   r   normr_   
rotary_embgradient_checkpointing	post_initr   s      r2   r+   zMiniCPM3Model.__init__  s     !.. ++7v1143C3CQWQaQa
 mmFKFLdLdFef!&)4f
 $F$6$6F<O<OP	1@&+# 	 gs   DNr4   r   r   r   inputs_embedsr  r   rI   c           
      <   |d u |d uz  rt        d      || j                  |      }|r|t        | j                        }|V||j	                         nd}t        j                  |j                  d   |j                        |z   }|j                  d      }t        | j                  ||||      }	|}
| j                  |
|      }| j                  d | j                  j                   D ]  } ||
f|	||||d|}
 | j                  |
      }
t        |
|	      S )
Nz:You must specify exactly one of input_ids or inputs_embedsr"  r   r   )rm   )ra   r.  r   r   r   )r   )r   r   r   r   r  )last_hidden_stater   )
ValueErrorr&  r
   ra   get_seq_lengthr.   rv   r\   rm   r   r   r+  r)  r  r*  r   )r0   r4   r   r   r   r.  r  r   past_seen_tokenscausal_maskrO   r   decoder_layers                r2   r7   zMiniCPM3Model.forward  sL    -t";<YZZ *.*;*;I*FM0*$++>OCRC^==?de <<(;(;A(>}G[G[\_ooL'11!4L(;;')+%
 &"oom,oW![[)H4;;+H+HI 		M)*$7) /# M		 		-0&++
 	
r3   )NNNNNN)r<   r=   r>   r    r+   r   r   r   r.   r  rB   r	   FloatTensorr  r   r   r   r7   rC   rD   s   @r2   r   r     s    ~ $   .2.204(,26!%2
##d*2
 t+2
 &&-	2

 2
 ((4/2
 $;2
 +,2
 
!2
    2
r3   r   c                   B    e Zd ZddiZddiZddgdgfiZ fdZee	 	 	 	 	 	 	 	 dd	e	j                  dz  d
e	j                  dz  de	j                  dz  dedz  de	j                  dz  de	j                  dz  dedz  dee	j                  z  dee   defd              Z xZS )MiniCPM3ForCausalLMzlm_head.weightzmodel.embed_tokens.weightlm_headcolwise_gather_outputrO   logitsc                     t         |   |       t        |      | _        |j                  | _        t        j                  |j                  |j                  d      | _        | j                          y )NFr   )
r*   r+   r   r  r$  r   r   rN   r9  r-  r   s     r2   r+   zMiniCPM3ForCausalLM.__init__  sU     "6*
 ++yy!3!3V5F5FUS 	r3   Nr4   r   r   r   r.  labelsr  logits_to_keepr   rI   c	           
          | j                   d||||||d|	}
|
j                  }|| j                  j                  z  }t	        |t
              rt        | d      n|}| j                  |dd|ddf         }d}|* | j                  d||| j                  j                  d|	}t        |||
j                  |
j                  |
j                        S )a  
        Example:

        ```python
        >>> from transformers import AutoTokenizer, MiniCPM3ForCausalLM

        >>> model = MiniCPM3ForCausalLM.from_pretrained("openbmb/MiniCPM3-4B")
        >>> tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM3-4B")

        >>> prompt = "Hey, are you conscious? Can you talk to me?"
        >>> inputs = tokenizer(prompt, return_tensors="pt")

        >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
        >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
        "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
        ```)r4   r   r   r   r.  r  N)r;  r=  r$  )lossr;  r   rO   r  r  )r  r0  ra   logits_scalingr   r@   slicer9  loss_functionr$  r   r   rO   r  )r0   r4   r   r   r   r.  r=  r  r>  r   outputsrO   slice_indicesr;  r@  s                  r2   r7   zMiniCPM3ForCausalLM.forward   s    < ,64:: ,
)%+',
 ,
  11%(B(BB8B>SV8W~ot4]kmA}a,?@A%4%%pVFt{{OeOepiopD%#33!//))
 	
r3   )NNNNNNNr   )r<   r=   r>   _tied_weights_keys_tp_plan_pp_planr+   r   r   r.   r  rB   r	   r6  r  r@   r   r   r   r7   rC   rD   s   @r2   r8  r8    s   *,GH23H_-z:;H  .2.204(,26*.!%-.6
##d*6
 t+6
 &&-	6

 6
 ((4/6
   4'6
 $;6
 ell*6
 +,6
 
 6
  6
r3   r8  c                       e Zd Zy)!MiniCPM3ForSequenceClassificationN)r<   r=   r>   r  r3   r2   rJ  rJ  ;  s    r3   rJ  )r  r   r8  rJ  )r   )r   )Gr  collections.abcr   typingr   r.   torch.nn.functionalr   r   r    r   r  activationsr   cache_utilsr	   r
   
generationr   integrationsr   r   masking_utilsr   modeling_layersr   r   modeling_outputsr   r   modeling_rope_utilsr   r   modeling_utilsr   r   processing_utilsr   utilsr   r   r   utils.genericr   r   r   utils.output_capturingr   configuration_minicpm3r    	Embeddingr"   ModulerG   r_   r   rB   r@   r   rA   r   r   r   r   r   r  r   r8  rJ  __all__r  r3   r2   <module>r`     s  *  $      & ! . ) Q / [ O K F & I I e e 5 2S",, S Y'Jbii J (J(><bii ><B"))  	UU\\ 	U# 	U%,, 	U& %II%<<% 
% <<	%
 LL4'% % % '(%2( *+ ,2u)		 u)p)5 )X Jo J J0 H
+ H
 H
V F
1? F
 F
R	(HJa 	 sr3   