
    <h?{              (       ^   S SK r S SKrS SKrS SKJr  S SKJrJr  S SKrS SK	J
s  Jr  SSKJrJrJrJrJr  \R&                  " \5      rS rS rSqSqSqSqSqSS	S
.qS\\   4S jrS r S\\   4S jr!S r"S<S jr#S r$S\RJ                  S\&\RJ                  \RJ                  \'4   4S jr(S\RJ                  S\RJ                  S\RJ                  S\RJ                  S\'4
S jr)S=S\*4S jjr+S r,S r-S r. S<S\RJ                  S \RJ                  S!\RJ                  S"\\R^                     4S# jjr0 " S$ S%\S&S'9r1        S>S\'S(\'S)\*S*\2S+\\2   S,\\'   S-\*S.\\2   S/\\*   S0\\RJ                     S1\\3\\*4      4S2 jjr4             S?S3\RJ                  S4\RJ                  S5\RJ                  S\\RJ                     S\'S)\*S*\2S6\\RJ                     S+\\2   S,\\'   S-\*S.\\2   S/\\*   S7\\Rj                     S8\\Rj                     S9\\'   S:\\'   S"\\R^                     S\\   4&S; jjr6g)@    N)partial)Optional	TypedDict   )is_flash_attn_2_availableis_flash_attn_3_available#is_flash_attn_greater_or_equal_2_10is_torch_npu_availableloggingc                  x    [        5       (       a  g[        5       (       a  [        5       (       + $ SSKJn   U " 5       $ )NFr   'is_npu_fa2_top_left_aligned_causal_mask)r   r   r	    integrations.npu_flash_attentionr   r   s    c/var/www/html/shao/venv/lib/python3.13/site-packages/transformers/modeling_flash_attention_utils.py!flash_attn_supports_top_left_maskr   $   s/     "" ""6888Y244    c                  Z    [        5       =(       d    [        5       =(       d
    [        5       $ N)r   r   r
    r   r   is_flash_attn_availabler   0   s    $&a*C*EaI_Iaar   	dropout_pwindow_size)dropoutsliding_windowimplementationc                 `   [        5       n[        5       nU S:X  d  U c  U(       a  U(       d  SSKJnJn  SSKJnJn  Oo[        [        peU S:X  d
  U c  U(       a	  SSK
JnJn  OK[        5       (       a  SSKJn  SS	KJn  O/[        U S
S5      n[        U SS5      nUb  Uc  [!        SU  S35      eX4XV4$ )a  
Lazy loads the respective flash attention implementations.

Return:
    flash_attn_func: The base flash attention function.
    flash_attn_varlen_func: The flash attention function supporting variable sequence lengths,
                            e.g. for padding-free training.
    pad_input: The function to pad inputs into one sequence and returning the respective kwargs.
    unpad_input: The function to unpad outputs based on the kwargs (from pad_input).
flash_attention_2Nr   )flash_attn_funcflash_attn_varlen_func)	pad_inputunpad_inputflash_attention_3r   )npu_flash_attn_func)npu_flash_attn_varlen_funcr   r   zJCould not find the currently requested flash attention implementation at `z^`.Make sure that you request a valid kernel from the hub, e.g. `kernels-community/flash-attn`.)r   r   
flash_attnr   r   flash_attn.bert_paddingr    r!   
_pad_input_unpad_inputflash_attn_interfacer
   r   r#   r$   getattr
ValueError)r   is_fa2is_fa3r   r   r    r!   s          r   _lazy_importsr.   C   s     '(F&(F,,1GF[aFBB!+\;00^5KPVTT#%%`n &n6GNO%,^=UW[%\"%-1H `ao`p qs t 
 IJJr   c                     [         R                  " U 5      R                  n[         R                  " [        5      R                  n0 nU H  n[        R                  XD5      nXQ;   X5'   M      [        [        US9$ )a  
Depending on the version and kernel some features are not supported. Due to limitations in
`torch.compile`, we opt to statically type which (optional) kwarg parameters are supported
within `_process_flash_attention_kwargs`.

NOTE: While all supported kwargs are marked as `True`, everything else is marked as `False`.
      This might be confusing for kwargs that we use in any case, e.g. `is_causal`.
)supports_mapping)inspect	signature
parameters_process_flash_attention_kwargs_hf_api_to_flash_mappinggetr   )flash_functionflash_parametersprocess_parametersr0   paramfa_params         r   _lazy_define_process_functionr<   g   sp     ((8CC **+JKVV#+//=%-%A" $ 2EUVVr   c                     [        S [        [        [        [        4 5       5      (       a  [        U 5      u  qqqq[        c  [        [        5      q[        [        [        [        4[        4$ )a
  
Lazy loading flash attention and returning the respective functions + flags back

NOTE: For fullgraph, this needs to be called before compile while no fullgraph can
      can work without preloading. See `_check_and_adjust_attn_implementation` in `modeling_utils`.
c              3   &   #    U H  oS L v   M
     g 7fr   r   ).0ks     r   	<genexpr>.lazy_import_flash_attention.<locals>.<genexpr>   s     
PO9O   )any	_flash_fn_flash_varlen_fn_pad_fn	_unpad_fnr.   _process_flash_kwargs_fnr<   )r   s    r   lazy_import_flash_attentionrJ   }   s]     
Py*:GYO
PPP:G:W7	#Wi  '#@AQ#R ')<>VVVr   c                 J    U R                   " S/U R                  SS Q76 nX!   $ )z
A local implementation of the PyTorch indexing operation `tensor[indices]` on the first axis,
after flattening the first two dimensions of the tensor. This is functionally equivalent to
FA2's `index_first_axis` and replaces the need to import it.
   N)reshapeshape)tensorindicesreshaped_tensors      r   _index_first_axisrS      s+     nnR;&,,qr*:;O##r   c                    Ub  X-   OUnUR                  S[        R                  S9nUR                  S[        R                  S9n[        R                  " UR	                  5       SS9R	                  5       nUR                  5       R                  5       n[        R                  " [        R                  " US[        R                  S9S5      n[        X5      UUUU4$ )a  
unpad_input function for flash attention variants that do not have them within their pkg themselves, e.g. fa3.

Arguments:
    hidden_states: (batch, seqlen, ...)
    attention_mask: (batch, seqlen), bool / int, 1 means valid and 0 means not valid.
    unused_mask: (batch, seqlen), bool / int, 1 means the element is allocated but unused.

Return:
    hidden_states: (total_nnz, ...), where total_nnz = number of tokens selected in attention_mask + unused_mask.
    indices: (total_nnz), the indices of masked tokens from the flattened input sequence.
    cu_seqlens: (batch + 1), the cumulative sequence lengths, used to index into hidden_states.
    max_seqlen_in_batch: int
    seqused: (batch), returns the number of tokens selected in attention_mask + unused_mask.
rL   dimdtypeFas_tupler   r   r   )sumtorchint32nonzeroflattenmaxitemFpadcumsumrS   )	hidden_statesattention_maskunused_mask	all_masksseqlens_in_batchused_seqlens_in_batchrQ   max_seqlen_in_batch
cu_seqlenss	            r   r(   r(      s      3>2I-~I }}5;;}?*..2U[[.ImmI--/%@HHJG*..0557u||$4!5;;OQWXJ 	-1 r   c                     U R                   SS n[        R                  " X#-  /UQ7U R                  U R                  S.6nXU'   UR
                  " X#/UQ76 $ )a  
pad_input function for flash attention variants that do not have them within their pkg themselves, e.g. fa3.

Arguments:
    hidden_states: (total_nnz, ...), where total_nnz = number of tokens in selected in attention_mask.
    indices: (total_nnz), the indices that represent the non-masked tokens of the original padded input sequence.
    batch: int, batch size for the padded sequence.
    seqlen: int, maximum sequence length for the padded sequence.

Return:
    hidden_states: (batch, seqlen, ...)
r   NdevicerW   )rO   r\   zerosro   rW   view)re   rQ   batchseqlenrV   outputs         r   r'   r'      sZ     

ab
!C[[%.hCh8L8LTaTgTghF#7O;;u+s++r   rf   returnc                 X   U R                  S[        R                  S9n[        R                  " U R	                  5       SS9R	                  5       nUR                  5       R                  5       n[        R                  " [        R                  " US[        R                  S9S5      nUUU4$ )aA  
Retrieves indexing data required to repad unpadded (ragged) tensors.

Arguments:
    attention_mask (`torch.Tensor`):
        Boolean or int tensor of shape (batch_size, sequence_length), 1 means valid and 0 means not valid.

Return:
    indices (`torch.Tensor`):
        The indices of non-masked tokens from the flattened input sequence.
    cu_seqlens (`torch.Tensor`):
        The cumulative sequence lengths, used to index into ragged (unpadded) tensors. `cu_seqlens` shape is (batch_size + 1,).
    max_seqlen_in_batch (`int`):
        Maximum sequence length in batch.
rL   rU   FrX   r   rZ   )
r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   )rf   ri   rQ   rk   rl   s        r   _get_unpad_datarw      s      &))b)DmmN224uEMMOG +..0557u||$4!5;;OQWXJ r   query_layer	key_layervalue_layerquery_lengthc                     [        U5      u  pgnUR                  S   UR                  S   =n	:  a!  USS2SU	2SS2SS24   USS2SU	2SS2SS24   p!UR                  u  pp[        X5      n[        X&5      nXK:X  a  [        X5      n UnUnUnOhUS:X  aJ  Sn[        R                  " U
S-   [        R
                  U R                  S9nUSS nU R                  S5      n OUSS2U* S24   nU" X5      tn npnU UUUX4X44$ )a  
Unpads query, key, and values tensors, using a single dimension for all tokens even though they belong to different batches.
This function is used instead of `flash_attn.bert_padding.unpad_input` in order to avoid the recomputation of the same intermediary
tensors for query, key, value tensors.

Arguments:
    query_layer (`torch.Tensor`):
        Query state with padding. Shape: (batch_size, query_length, num_heads, head_dim).
    key_layer (`torch.Tensor`):
        Key state with padding. Shape: (batch_size, kv_seq_len, num_key_value_heads, head_dim).
    value_layer (`torch.Tensor`):
        Value state with padding. Shape: (batch_size, kv_seq_len, num_key_value_heads, head_dim).
    attention_mask (`torch.Tensor`):
        Boolean or int tensor of shape (batch_size, sequence_length), 1 means valid and 0 means not valid.
    query_length (`int`):
        Target length.
    unpad_input_func:
        The function to use for unpadding the input tensors.

Return:
    query_layer (`torch.Tensor`):
        Query state without padding. Shape: (total_target_length, num_heads, head_dim).
    key_layer (`torch.Tensor`):
        Key state with padding. Shape: (total_source_length, num_key_value_heads, head_dim).
    value_layer (`torch.Tensor`):
        Value state with padding. Shape: (total_source_length, num_key_value_heads, head_dim).
    indices_q (`torch.Tensor`):
        The indices of non-masked tokens from the flattened input target sequence.
    (cu_seqlens_q, cu_seqlens_k) (`tuple[int]`):
        The cumulative sequence lengths for the target (query) and source (key, value), used to index into ragged (unpadded) tensors. `cu_seqlens` shape is (batch_size + 1,).
    (max_seqlen_in_batch_q, max_seqlen_in_batch_k) (`tuple[int]`):
        Maximum sequence length in batch (`max_seqlen_in_batch_q` for the target sequence i.e. query, `max_seqlen_in_batch_k` for the source sequence i.e. key/value).
r   rL   NrW   ro   )rw   rO   rS   r\   aranger]   ro   squeeze)rx   ry   rz   rf   r{   unpad_input_func	indices_kcu_seqlens_kmax_seqlen_in_batch_kseq_len
batch_size
kv_seq_lennum_key_value_headshead_dimcu_seqlens_qmax_seqlen_in_batch_q	indices_q_s                     r   _upad_inputr      sE   R 6E^5T2I2 q(<(<R(@@WA!*1hwh1+<!={1hwhXY[\K\?];<EOO9J/!)7I#K;K!'?# 5			 !||N%++k6H6H
 !"%	!))!, (L=>(9:JZ[fJwGYa 		$	6 r   is_packed_sequencec           	         U(       Gdg  [         R                  U R                  S.nU SS2S4   nU R                  S   S:X  a&  [         R                  " U R                  S5      40 UD6OUR                  S5      n[         R                  " [         R                  " S0 UD6UR                  S5      R                  [         R                  5      /S5      n[         R                  " [         R                  " S0 UD6UR                  S5      R                  S5      R                  [         R                  5      /S5      n[        UR                  5       5      n[        UR                  5       5      S-   nOU R                  5       n [         R                  " U R                  S5      U R                  [         R                  S9n	[         R                  " XS:H     [         R                  " U R                  5       U R                  [         R                  S945      nUnUR!                  5       R                  5       nUR#                  5       nUnXV4Xx44$ )a  
This function returns all the necessary kwargs to call `flash_attn_varlen_func`
extracted from position_ids. The `position_ids` can be either packed sequence or
the usual padded position ids, for example in inference time.

Arguments:
    position_ids (`torch.Tensor`):
        Boolean or int tensor of shape (batch_size, sequence_length), 1 means valid and 0 means not valid.
    is_packed_sequence (`bool`, *optional*, defaults to `True`):
        Whether the input position ids are a packed sequence or not.

Return:
    (cu_seqlens_q, cu_seqlens_k) (`tuple[int]`):
        The cumulative sequence lengths for the target (query) and source (key, value), used to index into
        ragged (unpadded) tensors. `cu_seqlens` shape is (batch_size + 1,).
    (max_seqlen_in_batch_q, max_seqlen_in_batch_k) (`tuple[int]`):
        Maximum sequence length in batch (`max_seqlen_in_batch_q` for the target sequence i.e. query,
        `max_seqlen_in_batch_k` for the source sequence i.e. key/value).
r}   NrL   r   r   rn   )r   )r\   r]   ro   rO   onessizeaddcatrp   rd   tointr`   r_   r~   rP   diffra   )
position_idsr   tensor_kwargslast_position_idsq_lencu_seq_lens_qcu_seq_lens_kmax_length_qmax_length_kr   s
             r   #prepare_fa_kwargs_from_position_idsr   :  s   . "'++9L9LM(B/ !!"%* JJ|((+=}="&&q) 	
 		5;;#BM#BELLQRODVDVW\WbWbDc"dfgh		[[,m,.?.C.CA.F.M.Ma.P.S.STYT_T_.`acd
 599;',0023a7#++-LL!2!21!5l>Q>QY^YdYde			!+,\..09L9LTYT_T_`
 &
 %))+//1 $((*#)L+GGGr   c                    UR                   S   nXE:H  nU R                  5       R                  SU R                  S5      U R                  S5      5      n UR                  5       R                  SUR                  S5      UR                  S5      5      nUR                  5       R                  SUR                  S5      UR                  S5      5      n[	        X6S9u  u  pxu  pXX'U4X44$ )a$  
This function returns necessary arguments to call `flash_attn_varlen_func`.
All three query, key, value states will be flattened.
Cumulative lengths of each examples in the batch will be extracted from position_ids.
NOTE: ideally cumulative lengths should be prepared at the data collator stage

Arguments:
    query (`torch.Tensor`):
        Query state with padding. Shape: (batch_size, query_length, num_heads, head_dim).
    key (`torch.Tensor`):
        Key state with padding. Shape: (batch_size, kv_seq_len, num_key_value_heads, head_dim).
    value (`torch.Tensor`):
        Value state with padding. Shape: (batch_size, kv_seq_len, num_key_value_heads, head_dim).
    position_ids (`torch.Tensor`):
        Boolean or int tensor of shape (batch_size, sequence_length), 1 means valid and 0 means not valid.
    query_length (`int`):
        Sequence length of the input queries.

Return:
    query (`torch.Tensor`):
        Query state without padding. Shape: (total_target_length, num_heads, head_dim).
    key (`torch.Tensor`):
        Key state with padding. Shape: (total_source_length, num_key_value_heads, head_dim).
    value (`torch.Tensor`):
        Value state with padding. Shape: (total_source_length, num_key_value_heads, head_dim).
    indices_q (`torch.Tensor`):
        The indices of non-masked tokens from the flattened input target sequence.
    (cu_seqlens_q, cu_seqlens_k) (`tuple[int]`):
        The cumulative sequence lengths for the target (query) and source (key, value), used to index into ragged (unpadded) tensors. `cu_seqlens` shape is (batch_size + 1,).
    (max_seqlen_in_batch_q, max_seqlen_in_batch_k) (`tuple[int]`):
        Maximum sequence length in batch (`max_seqlen_in_batch_q` for the target sequence i.e. query, `max_seqlen_in_batch_k` for the source sequence i.e. key/value).
r   rL   )r   )rO   
contiguousrq   r   r   )querykeyvaluer   r{   	kv_lengthr   r   r   r   r   s              r   _prepare_from_posidsr   |  s    B 		!I%2##B

2

2GE
..


CHHRL#((2,
?C##B

2

2GECfD@"]$@\ }=?[\\r   c                 P    [         R                  " S[        5        [        XX#5      $ )NzThe function `_prepare_flash_attention_from_position_ids` in `transformers.modeling_flash_attention_utils` is deprecated and will be removed in a future version. Please use `_prepare_from_posids` instead.)warningswarnFutureWarningr   )r   r   r   r   s       r   *_prepare_flash_attention_from_position_idsr     s&    MM 	W  E@@r   c                     U c  g[         R                  " U R                  S   U R                  S9U R	                  5       -   nUS:H  =(       a.    X -
  R                  5       R                  5       R                  5       $ )a  
Check the position ids whether packed sequences are indicated or not
    1. Position ids exist
    2. Flattened sequences only are supported
    3. Compile-friendly `not (torch.diff(position_ids, dim=-1) >= 0).all()`, i.e. we have multiple increasing sequences
Fr   )ro   )r\   r~   rO   ro   minabsr[   bool)r   r   increasing_position_sequencess      r   _is_packed_sequencer     sq      	\''*<3F3FG,JZJZJ\\ " ?` = LQQSWWY^^``r   qr@   vtarget_dtypec                     U(       ai  U R                   [        R                  :X  aK  [        R	                  SU S35        U R                  U5      UR                  U5      UR                  U5      p!n XU4$ )aM  
PEFT usually casts the layer norms in float32 for training stability reasons
therefore the input hidden states gets silently casted in float32. Hence, we need
cast them back in float16 / bfloat16 just to be sure everything works as expected.
This might slowdown training & inference so it is recommended to not cast the LayerNorms!
zCasting fp32 inputs back to z for flash-attn compatibility.)rW   r\   float32loggerwarning_oncer   )r   r@   r   r   s       r   fa_peft_integration_checkr     s^     5==0:<.Hfgh$$|$add<&8!$$|:La7Nr   c                       \ rS rSr% Sr\\R                     \S'   \\R                     \S'   \\	   \S'   \\	   \S'   Sr
g)	FlashAttentionKwargsi  a  
Keyword arguments for Flash Attention with Compile.

Attributes:
    cumulative_seqlens_q (`torch.LongTensor`, *optional*)
        Gets cumulative sequence length for query state.
    cumulative_seqlens_k (`torch.LongTensor`, *optional*)
        Gets cumulative sequence length for key state.
    max_length_q (`int`, *optional*):
        Maximum sequence length for query state.
    max_length_k (`int`, *optional*):
        Maximum sequence length for key state.
cumulative_seqlens_qcumulative_seqlens_kr   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r\   
LongTensor__annotations__r   __static_attributes__r   r   r   r   r     s?     #5#3#344"5#3#3443-3-r   r   F)total
key_length	is_causalr   softmax_scaler   use_top_left_masksoftcapdeterministics_auxr0   c                 ,   U=(       a    U=(       a    U S:H  (       + US.nU
S   (       a  X<S'   U
S   (       a  Ub  X:  a  XU4US'   U
S   (       a"  Ub  UO[         R                  " SS5      S:H  US'   U
S	   (       a  Ub  X|S	'   U
S
   (       a  U	b  XS
'   U$ )a  
Returns a set of kwargs that are passed down to the according flash attention function based on
requested features and whether it is supported - depends on the version and kernel implementation
which is dynamically configued at `lazy_import_flash_attention`. The (un)supported features can be
inspected in `supports_mapping`, see `_lazy_define_process_function` for more details.

Args:
    query_length (`int`):
        Length of the query states
    key_length (`int`):
        Length of the key states
    is_causal (`bool`):
        Whether we perform causal (decoder) attention or full attention.
    dropout (`float`):
        Attention dropout.
    softmax_scale (`float`, *optional*):
        The scaling of QK^T before applying softmax. Default to `1 / sqrt(head_dim)`.
    sliding_window (`int`, *optional*):
        The size of the sliding window, i.e. we look at a max of `sliding_window` tokens back.
    use_top_left_mask (`bool`):
        Deprecated behavior of older versions of flash attention requiring different masking.
    softcap (`float`, *optional*):
        Softcap for the attention logits, used e.g. in gemma2.
    deterministic (`bool`, *optional*):
        Determines if the deterministic option introduced in flash_attn>=2.4.1 is enabled.
    s_aux (`torch.Tensor`, *optional*):
        Attention sink auxiliary that adds a `bias` to the attention calculation via an additional head.
Return:
    flash_kwargs (`dict`):
        A dict of kwargs that are requested and supported.
r   )causalr   r   r   r   FLASH_ATTENTION_DETERMINISTIC01r   r   )osgetenv)r{   r   r   r   r   r   r   r   r   r   r0   kwargsflash_kwargss                r   r4   r4     s    \ M%6%L<1;L M&L
 $$+[!&>+E*Je'5&F]#(*6MBIIFegj<kor<r 	_% 	"w':")Y  U%6 %Wr   query_states
key_statesvalue_statesr   r   r   r   r   c                    [        U5      u  u  nnnnn[        XUU5      u  pnU" SUUR                  S5      UUUU	U
UUS.	UD6n[        XpR                  S5      S9n[	        S XUU4 5       5      nUb  [        XX#UU5      u  nnnnu  pu  nnS[        UR                  5      ;   a  UR                  5       nU" UUU4UUUUS.UD6n [        U [        5      (       a  U S   n U" U UU R                  S5      U5      n!U!$ U(       d  U(       GaF  Ub  Uc  [        XX'US9u  nnnu  pu  nnOU R                  S	U R                  S
5      U R                  S	5      5      nUR                  S	UR                  S
5      UR                  S	5      5      nUR                  S	UR                  S
5      UR                  S	5      5      nS[        UR                  5      ;   a  UR                  5       nU" UUU4UUUUS.UD6n![        U![        5      (       a  U!S   n!U!R                  U R                  S5      S	U!R                  S
5      U!R                  S	5      5      n!U!$ U" XU40 UD6n![        U![        5      (       a  U!S   n!U!$ )a  
Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
first unpad the input, then computes the attention scores and pad the final attention scores.

(Optional) kwargs are described further in `_process_flash_attention_kwargs` and `FlashAttentionKwargs`.

Args:
    query_states (`torch.Tensor`):
        Input query states to be passed to Flash Attention API
    key_states (`torch.Tensor`):
        Input key states to be passed to Flash Attention API
    value_states (`torch.Tensor`):
        Input value states to be passed to Flash Attention API
    attention_mask (`torch.Tensor`, *optional*):
        The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
        position of padding tokens and 1 for the position of non-padding tokens.
    implementation (`str`, *optional*):
        The attention implementation to use. If None, will default to the one based on the environment.
r   )	r{   r   r   r   r   r   r   r   r   r   )r   c              3   &   #    U H  oS Lv   M
     g 7fr   r   )r?   kwargs     r   rA   +_flash_attention_forward.<locals>.<genexpr>y  s      #'aeT'arC   mps)r   r   max_seqlen_qmax_seqlen_k)r{   rL   r   r   )rJ   r   r   r   allr   strro   clone
isinstancetupler   rN   rq   )"r   r   r   rf   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   flash_fnflash_varlen_fnpad_fnunpad_fnprocess_flash_kwargs_fnr   is_fa_with_position_idsis_fa_with_varlen_kwargsr   r@   r   r   	out_unpadouts"                                     r   _flash_attention_forwardr   1  s   R NiNJ1X3J
 .G,.*Ll
 + !??1%#%+# L( 2,K\K\]^K_`" #(5lT`'a#  
 ![flLRZ\
X1a:]<X\< CM!)//1M#	
 '&%%	
 	
	 i''!!IY	<+<+<Q+?NN JI 
"%< M$9Th,S_UQAq!3m5QlL $$R):):2)>@Q@QRT@UVA""2zr':JOOB<OPA$$R):):2)>@Q@QRT@UVA CM!)//1M	
 '&%%	
 	
 c5!!a&Chh|((+R"sxx|L J	 |NNc5!!a&CJr   r   )T)        NNFNNNN)r   NNNFNNNNNNNN)7r1   r   r   	functoolsr   typingr   r   r\   torch.nn.functionalnn
functionalrb   utilsr   r   r	   r
   r   
get_loggerr   r   r   r   rE   rF   rG   rH   rI   r5   r   r.   r<   rJ   rS   r(   r'   Tensorr   r   rw   r   r   r   r   r   r   rW   r   r   floatdictr4   r   r   r   r   r   <module>r      s    	   &     
		H	%5b
 	 
	    # !K(3- !KHW,W W$	$@,&ELL U5<<WZ;Z5[ :LL||L L LL	L
 L^?H$ ?HD,]^Aa( +/	|||| || 5;;'	$ 9E  2 %)$(##$($(26DDD D 	D
 E?D SMD D e_D D>D ELL!D tCI/D\ +/%)$(##$(0404"&"&*.$('K,,KK ,,K U\\*	K
 K K K 5<<(K E?K SMK K e_K D>K E,,-K E,,-K  3-!K" 3-#K$ 5;;'%K& SM'Kr   