ó
    †ñ:i„K  ã                  óØ   • S SK Jr  S SKrS SKJrJrJr  S SKrSSK	J
r
  SSKJr  SSKJr  SSKJrJrJr   " S	 S
\5      r " S S5      rS rS rS rS rS rS rS rS rS rS rS rg)é    )ÚannotationsN)ÚchainÚcombinationsÚproducté   )Úlinks)Ú	Explainer)ÚModel)ÚMaskedModelÚ
make_masksÚsafe_isinstancec                  ó�   ^ • \ rS rSrSrS\R                  SSSS.U 4S jjrSSSSS	SSS
.U 4S jjrSSSS	SSS	S.S jr	S r
SrU =r$ )ÚCoalitionExplaineré   aØ  A coalition-based explainer that uses Winter values, also called recursive Owen values, to explain model predictions.

This explainer implements a coalition-based approach to compute feature attributions
using Winter values, which extend Shapley values to handle hierarchical feature groupings.
Essentially the attributions are computed using the marginals respecting the partition tree, reducing the complexity of computation.

It is particularly useful when features can be grouped into coalitions or
hierarchies, in the case of temporal, multimodal data (e.g., demographic features, financial features, etc.).
Textual and image data is not yet implemented.

The explainer supports both single and multi-output models, and can handle various
types of input data through the provided masker.

Example usage
--------
>>> import shap
>>> import numpy as np
>>> import pandas as pd
>>> from sklearn.ensemble import RandomForestClassifier
>>> from sklearn.datasets import load_iris
>>>
>>> # Load data and train model
>>> X, y = load_iris(return_X_y=True)
>>> model = RandomForestClassifier().fit(X, y)
>>>
>>> # Define feature groups
>>> coalition_tree = {
...     "Sepal": ["sepal length (cm)", "sepal width (cm)"],
...     "Petal": ["petal length (cm)", "petal width (cm)"]
... }
>>> # Define feature names, or you can pass X as a DataFrame
>>> feature_names = ["sepal length (cm)", "sepal width (cm)",
             "petal length (cm)", "petal width (cm)"]
>>> masker = shap.maskers.Partition(X)
>>> masker.feature_names = feature_names
>>>
>>> # Create explainer
>>> explainer = shap.CoalitionExplainer(
...     model.predict,
...     masker,
...     partition_tree=coalition_tree
... )
>>>
>>> # Compute SHAP values
>>> shap_values = explainer(X[:5]
NT)Úoutput_namesÚlinkÚlinearize_linkÚfeature_namesÚpartition_treec          
     óš  >^ • [         TT ]  UUUUSUUS9  [        US5      (       a)  [        UR                  5      (       d  UR                  SS OST l        [        T R                  S5      (       d  [        T R                  5      T l        ST l	        ST l
        T R
                  b%  [        T R
                  5      S:”  a  U 4S jT l        OT R                  T l        Uc  [        S5      eUT l        [        T R                  R                   5      (       d6  T R                  R                   T l        [%        T R"                  5      T l        gg)	až  Initialize the coalition explainer with a model and masker.

Parameters
----------
model : callable or shap.models.Model
    A callable that takes a matrix of samples (# samples x # features) and
    computes the output of the model for those samples. The output can be a vector
    (# samples) or a matrix (# samples x # outputs).

masker : shap.maskers.Masker
    A masker object that defines how to mask features and compute background
    values. This should be compatible with the input data format.

output_names : list of str, optional
    Names for each of the model outputs. If None, the output names will be
    determined from the model if possible.

link : callable, optional
    The link function used to map between the output units of the model and the
    SHAP value units. By default, the identity function is used.

linearize_link : bool, optional
    If True, the link function is linearized around the expected value to
    improve the accuracy of the SHAP values. Default is True.

feature_names : list of str, required
    Names for each of the input features. If None, feature names will be
    determined from the masker if possible.

partition_tree : dict, required
    A dictionary defining a custom hierarchical grouping of features. This is for users who want to
    define partitions based on domain knowledge. For automatic binary clustering, please use the
    `PartitionExplainer`. Each key represents a group name, and its value is either a list of
    feature names or another dictionary defining subgroups. Note all input features must be included
    in the leaf nodes.
    For example:
    {
        "Demographics": ["Age", "Gender", "Education"],
        "Financial": {
            "Income": ["Salary", "Bonus"],
            "Assets": ["Savings", "Investments"]
        }
    }

Notes
-----
- The explainer supports both single and multi-output models.
- The partition_tree parameter is used to define feature coalitions for
  computing Owen values, which can provide more meaningful explanations
  when features are naturally grouped.
- The masker should be compatible with the input data format and provide
  appropriate background values for computing SHAP values.
Ú	partition)r   r   Ú	algorithmr   r   Úshapeé   Nzshap.models.Modelc                óv   >• TR                  U R                  " U R                  S   /TR                  Q76 5      $ ©Nr   )ÚmodelÚreshaper   Úinput_shape)ÚxÚselfs    €Ú]/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/shap/explainers/_coalition.pyÚ<lambda>Ú-CoalitionExplainer.__init__.<locals>.<lambda>�   s*   ø€ ¨T¯Z©Z¸¿	º	À!Ç'Á'È!Á*Ð8`Èt×O_ÑO_Ò8`Ô-aó    z½A `partition_tree` must be provided to CoalitionExplainer. This explainer is for custom user-defined partitions. For automatic hierarchical clustering, please use `shap.PartitionExplainer`.)ÚsuperÚ__init__ÚhasattrÚcallabler   r   r   r   r
   Úexpected_valueÚ_curr_base_valueÚlenÚ_reshaped_modelÚ
ValueErrorr   ÚmaskerÚ
clusteringÚ_clusteringr   Ú_mask_matrix)	r!   r   r/   r   r   r   r   r   Ú	__class__s	   `       €r"   r'   ÚCoalitionExplainer.__init__?   s)  ù€ ô@ 	‰ÑØØØØ)Ø!Ø%Ø'ð 	ñ 	
ô 07°v¸w×/GÑ/GÔPXÐY_×YeÑYe×PfÑPf˜6Ÿ<™<¨¨Ñ+ÐlpˆÔÜ˜tŸz™zÐ+>×?Ñ?Ü˜tŸz™zÓ*ˆDŒJà"ˆÔØ $ˆÔà×ÑÑ'¬C°×0@Ñ0@Ó,AÀAÓ,EÜ#aˆDÕ à#'§:¡:ˆDÔ àÑ!Üð_óð ð
 -ˆÔä˜Ÿ™×.Ñ.×/Ñ/Ø#Ÿ{™{×5Ñ5ˆDÔÜ *¨4×+;Ñ+;Ó <ˆDÕð 0r%   iô  FÚauto©Ú	max_evalsÚfixed_contextÚmain_effectsÚerror_boundsÚ
batch_sizeÚoutputsÚsilentc               ó4   >• [         T
U ]  " UUUUUUUUS.U	D6$ )Nr6   )r&   Ú__call__)r!   r7   r8   r9   r:   r;   r<   r=   ÚargsÚkwargsr3   s             €r"   r?   ÚCoalitionExplainer.__call__    s9   ø€ ô ‰wÒØØØ'Ø%Ø%Ø!ØØñ

ð ñ

ð 
	
r%   éd   )r7   r9   r:   r;   r<   r=   r8   c               ó¨
  • US:X  a  S nOUS;  a  [        SU 35      e[        U R                  U R                  U R                  U R
                  /UQ76 n	[        U	5      n
[        R                  " U
[        S9nU R                  b  [        U R                  SS5      (       dR  U	" UR                  SS5      S	S
9S	   n[        U[        [        45      (       a  [        R                   " U5      OUU l
        [        U R                  [        R"                  5      (       aG  U R                  R$                  S	:”  a-  [        U R                  5      n[        R                  " X­45      nOSn[        R                  " U
5      n['        S5      U l        [+        U R,                  U R(                  5        [/        U R(                  5      U l        [3        U R(                  U R                  R4                  5      u  U l        U l        [;        [=        U R8                  U R6                  5      5      U l        [A        U R0                  U R>                  5      U l!        U RB                   VVs/ s H	  u  nnnUPM     snnU l"        [G        [I        [        U RD                  5      5      U l%        U RJ                   Vs/ s H  n[        R                   " U5      PM     snU l&        0 nU RL                   H‘  nU	" UR                  SS5      5      n[        U[        [        45      (       a  [        R                   " U5      nO6[        U[        R"                  5      (       d  [        R                   " U/5      nUU[        U5      '   M“     [O        U RB                  U RL                  5      u  nnn[Q        U R                  R4                  5       VVs0 s H	  u  nnUU_M     nnnU GH  nUU   nUU   nUU   n[=        UUU5       Hë  u  nnnU[        U RL                  U   5         n U[        U RL                  U   5         n!US:”  a‡  [        RR                  " U 5      R                  S5      n [        RR                  " U!5      R                  S5      n![U        U5       H,  n"[W        U!U"   U U"   -
  U-  5      n#UUU   U"4==   U#-  ss'   M.     MÊ  [W        U!U -
  U-  5      n#UUU   ==   U#-  ss'   Mí     GM     URY                  5       U R                  U	RZ                   V$s/ s H  n$U$S-   PM
     sn$S US U[        U R                  SS 5      S.$ s  snnf s  snf s  snnf s  sn$f )Nr5   )r   r   Nz;Unknown fixed_context value passed (must be 0, 1 or None): ©ÚdtypeÚfixed_backgroundFr   éÿÿÿÿr   )Ú
zero_indexÚRoot© r   )ÚvaluesÚexpected_valuesÚmask_shapesr9   Úhierarchical_valuesr0   Úoutput_indicesr   ).r.   r   r   r/   r   r   r,   ÚnpÚzerosÚboolr+   Úgetattrr   Ú
isinstanceÚlistÚtupleÚarrayÚndarrayÚndimÚNodeÚrootÚ_build_treer   Ú _generate_paths_and_combinationsÚcombinations_listÚ_create_masksr   ÚmasksÚkeysÚdictÚzipÚ
masks_dictÚ_create_combined_masksÚmask_permutationsÚ
masks_listÚsetÚmapÚunique_masks_setÚunique_masksÚ!_map_combinations_to_unique_masksÚ	enumerateÚasarrayÚrangeÚfloatÚcopyrN   )%r!   r7   r9   r:   r;   r<   r=   r8   Úrow_argsÚfmÚMÚm00Úbase_outputÚnum_outputsÚshap_valuesÚ_ÚmaskÚmask_resultsÚresultÚlast_key_to_off_indexesÚlast_key_to_on_indexesÚweightsÚidxÚnameÚfeature_name_to_indexÚlast_keyÚoff_indexesÚ
on_indexesÚweight_listÚ	off_indexÚon_indexÚweightÚ
off_resultÚ	on_resultÚiÚmarginal_contributionÚss%                                        r"   Úexplain_rowÚCoalitionExplainer.explain_row¹   s›  € ð ˜FÓ"Ø ‰MØ ,Ó.ÜÐZÐ[hÐZiÐjÓkÐkä˜Ÿ™ T§[¡[°$·)±)¸T×=PÑ=PÐ\ÐS[Ò\ˆô �‹GˆÜ�hŠh�q¤Ñ%ˆð × Ñ Ñ(´¸¿¹ÐEWÐY^×0_Ñ0_Ù˜SŸ[™[¨¨BÓ/¸AÑ>¸qÑAˆKÜ=GÈÔVZÔ\aÐUb×=cÑ=c¤B§H¢H¨[Ô$9ÐitˆDÔ!ô �d×+Ñ+¬R¯Z©Z×8Ñ8¸T×=RÑ=R×=WÑ=WÐZ[Ó=[Ü˜d×3Ñ3Ó4ˆKÜŸ(š( AÐ#3Ó4‰KàˆKÜŸ(š( 1›+ˆKô ˜“LˆŒ	Ü�D×'Ñ'¨¯©Ô3Ü!AØ�I‰Ió"
ˆÔô !.Ø�I‰I�t—{‘{×0Ñ0ó!
ÑˆŒ
�D”Iô œs 4§9¡9¨d¯j©jÓ9Ó:ˆŒÜ!7Ø×"Ñ" D§O¡Oó"
ˆÔð 37×2HÒ2HÔIÒ2H¡J A t¨Q›4Ñ2HÒIˆŒÜ #¤C¬¨t¯©Ó$?Ó @ˆÔØ8<×8MÒ8MÓNÒ8M°œRŸXšX dž^Ñ8MÑNˆÔð ˆØ×%Ô%ˆDÙ˜Ÿ™ Q¨Ó+Ó,ˆFä˜&¤4¬ -×0Ñ0ÜŸš &Ó)‘Ü ¬¯
©
×3Ñ3ÜŸš 6 (Ó+�Ø(.ˆLœ˜t›Ó%ñ &ô DeØ×"Ñ" D×$5Ñ$5óD
Ñ@ÐÐ!7¸ô =FÀdÇkÁk×F_ÑF_Ô<`Ô aÒ<`©y¨s°D  s¢Ñ<`ÐÑ aô 0ˆHØ1°(Ñ;ˆKØ/°Ñ9ˆJØ! (Ñ+ˆKä/2°;À
ÈKÖ/XÑ+�	˜8 VØ)¬%°×0AÑ0AÀ)Ñ0LÓ*MÑN�
Ø(¬¨t×/@Ñ/@ÀÑ/JÓ)KÑL�	à “?ä!#§¢¨JÓ!7×!?Ñ!?ÀÓ!C�JÜ "§
¢
¨9Ó 5× =Ñ =¸bÓ A�IÜ" ;Ö/˜Ü05°yÀ±|ÀjÐQRÁmÑ7SÐW]Ñ6]Ó0^Ð-Ø#Ð$9¸(Ñ$CÀQÐ$FÓGÐK`Ñ`ÕGó 0ô -2°9¸zÑ3IÈVÑ2SÓ,TÐ)ØÐ 5°hÑ ?Ó@ÐDYÑYÕ@ô 0Yñ 0ð, "×&Ñ&Ó(Ø#×4Ñ4Ø,.¯NªNÓ;ªN q˜A œF©NÑ;Ø Ø#.ØØ%Ü# D§J¡J°ÀÓEñ	
ð 		
ùóY JùâNùó$ !bùò6 <s   ÉT>Ê. UÎ?U	ÔUc                ó   • g)Nz$shap.explainers.CoalitionExplainer()rK   ©r!   s    r"   Ú__str__ÚCoalitionExplainer.__str__   s   € Ø5r%   )r1   r+   r2   r-   r_   r*   r   rb   rg   ra   re   rh   r   r   r\   rl   rk   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úidentityr'   r?   r�   r”   Ú__static_attributes__Ú__classcell__)r3   s   @r"   r   r      st   ø† ñ-ðh Ø�^‰^ØØØ÷_=ð _=ðH ØØØØØØ÷
ð 
ð8 ØØØØØØõe
÷N6ð 6r%   r   c                  ó    • \ rS rSrS rS rSrg)r[   i%  c                ó:   • Xl         / U l        / U l        / U l        g ©N©ÚkeyÚchildÚpermutationsr€   )r!   r¢   s     r"   r'   ÚNode.__init__&  s   € ØŒØˆŒ
ØˆÔØˆ�r%   c                ón   • SU R                    SU R                   SU R                   SU R                   3$ )NÚ(z): z -> z \ r¡   r“   s    r"   Ú__repr__ÚNode.__repr__,  s4   € Ø�4—8‘8�*˜C §
¡
˜|¨4°×0AÑ0AÐ/BÀ$ÀtÇ|Á|ÀnÐUÐUr%   )r£   r¢   r¤   r€   N)r–   r—   r˜   r™   r'   r¨   rœ   rK   r%   r"   r[   r[   %  s   † òõVr%   r[   c                ó¦  • [        U [        5      (       aK  U R                  5        H6  u  p#[        U5      nUR                  R                  U5        [        X45        M8     Of[        U [        5      (       aQ  U  HK  n[        U[        5      (       a  [        XQ5        M%  [        U5      nUR                  R                  U5        MM     [        U5        g r    )	rU   rc   Úitemsr[   r£   Úappendr]   rV   Ú_generate_permutations)Údr\   r¢   ÚvalueÚnodeÚitems         r"   r]   r]   1  s—   € Ü�!”T×ÑØŸ'™'ž)‰JˆCÜ˜“9ˆDØ�J‰J×Ñ˜dÔ#Ü˜Ö$ò $ô 
�A”t×	Ñ	ÛˆDÜ˜$¤×%Ñ%Ü˜DÖ'ä˜D“z�Ø—
‘
×!Ñ! $Ö'ñ ô ˜4Õ r%   c                ó\   ^ ^^• UUU 4S jm[        T 5      [        T5      -   S-
  nT" U5      $ )zFConverts a SciPy linkage matrix into a SHAP partition_tree dictionary.c                óÆ   >• U [        T5      :  a  TU    $ [        TU [        T5      -
  S4   5      n[        TU [        T5      -
  S4   5      nSU  3T" U5      T" U5      /0$ )Nr   r   Úgroup_)r,   Úint)r�   ÚleftÚrightÚbuild_final_treeÚcolumnsÚlinkage_matrixs      €€€r"   r¸   Ú4create_partition_hierarchy.<locals>.build_final_treeI  su   ø€ ØŒs�7‹|ÓØ˜1‘:ÐÜ�> !¤c¨'£lÑ"2°AÐ"5Ñ6Ó7ˆÜ�N 1¤s¨7£|Ñ#3°QÐ#6Ñ7Ó8ˆØ˜˜�Ñ/°Ó5Ñ7GÈÓ7NÐOÐPÐPr%   r   )r,   )rº   r¹   Ú	root_noder¸   s   `` @r"   Úcreate_partition_hierarchyr½   B  s.   ú€ ÷Qô �NÓ#¤c¨'£lÑ2°QÑ6€IÙ˜IÓ&Ð&r%   c                óD   • [         R                  R                  U 5      nU$ r    )rQ   Ú
logical_orÚreduce)ra   Úcombined_masks     r"   Ú_combine_masksrÂ   T  s   € Ü—M‘M×(Ñ(¨Ó/€MØÐr%   c                óB   • SU [         R                  " U S-
  U5      -  -  $ ©Nr   )ÚmathÚcomb)ÚtotalÚselecteds     r"   Ú_compute_weightrÉ   Y  s!   € Ø�œŸ	š	 %¨!¡)¨XÓ6Ñ6Ñ7Ð7r%   c                ón   ^ • [         R                  " U 4S j[        [        T 5      S-   5       5       5      $ )Nc              3  ó<   >#   • U  H  n[        TU5      v •  M     g 7fr    )r   )Ú.0ÚnÚiterables     €r"   Ú	<genexpr>Ú_all_subsets.<locals>.<genexpr>^  s   øé € Ð[ÒBZ¸Qœ|¨H°a×8Ð8ÒBZùs   ƒr   )r   Úfrom_iterablerp   r,   )rÎ   s   `r"   Ú_all_subsetsrÒ   ]  s)   ø€ Ü×ÒÔ[Ä%ÌÈHËÐXYÑHYÔBZÓ[Ó[Ð[r%   c                óÀ   • / nU R                   (       d  UR                  U R                  5        U$ U R                    H  nUR                  [	        U5      5        M     U$ r    )r£   r¬   r¢   ÚextendÚ_get_all_leaf_values)r°   Úleavesr£   s      r"   rÕ   rÕ   a  sL   € Ø€FØ�:�:Ø�‰�d—h‘hÔð €Mð —Z”ZˆEØ�M‰MÔ.¨uÓ5Ö6ñ  à€Mr%   c           
     ó¼  • U R                   (       d  / U l        g U R                    Vs/ s H  oR                  PM     nn0 U l        [        U R                   5       Ht  u  p1US U X#S-   S  -   n[	        U5        [        [        U5      5      Ul        UR                   Vs/ s H!  n[        [        U5      [        U5      5      PM#     snUl	        Mv     g s  snf s  snf rÄ   )
r£   r¤   r¢   rn   r­   rV   rÒ   rÉ   r,   r€   )r°   r£   Úchildren_keysr�   ÚexcludedÚpermutations         r"   r­   r­   l  sÀ   € Ø�:�:ØˆÔØà,0¯JªJÓ7ªJ 5—Y”Y©J€MÐ7Ø€DÔä˜dŸj™jÖ)‰ˆØ   !Ð$ }¸±U°WÐ'=Ñ=ˆÜ˜uÔ%ô "¤,¨xÓ"8Ó9ˆÔð ch×btÒbtÓuÒbtÐS^œ¬¨]Ó);¼SÀÓ=MÖNÑbtÑuˆŽò *ùò 8ùò vs   ¨CÂ(Cc                óF  • [         R                  " [        U5      [        S9/nS/nU R                  (       d�  [        US5      (       a  UR                  U R                  /5      nO3[         R                  " U Vs/ s H  oUU R                  :H  PM     sn5      nUR                  U5        UR                  U R                  5        X#4$ [        US5      (       a  UR                  [        U 5      5      nO4[        U 5      n[         R                  " U Vs/ s H  oUU;   PM	     sn5      nUR                  U5        UR                  U R                  5        U R                   H2  n[        X�5      u  pšUR                  U	5        UR                  U
5        M4     X#4$ s  snf s  snf )NrE   rK   Úisin)rQ   rR   r,   rS   r£   r(   rÜ   r¢   rX   r¬   rÕ   r`   rÔ   )r°   r¹   ra   rb   r{   ÚcolÚcurrent_node_maskÚleaf_valuesÚsubsetÚchild_masksÚ
child_keyss              r"   r`   r`   ƒ  sF  € Ü�XŠX”c˜'“l¬$Ñ/Ð0€EØˆ4€Dà�:�:Ü�7˜F×#Ñ#Ø—<‘< §¡ 
Ó+‰Dä—8’8¹Ó@º° D§H¡Hœ_¹Ñ@ÓAˆDØ�‰�TÔØ�‰�D—H‘HÔð ˆ;Ðô �7˜F×#Ñ#Ø '§¡Ô-AÀ$Ó-GÓ HÑä.¨tÓ4ˆKÜ "§¢ÉÓ)PÊÀ°Ô*<ÉÑ)PÓ QÐØ�‰Ð&Ô'Ø�‰�D—H‘HÔà—j”jˆFÜ&3°FÓ&DÑ#ˆKØ�L‰L˜Ô%Ø�K‰K˜
Ö#ñ !ð
 ˆ;Ðùò# Aùò *Qs   Á:FÄFc           	     óº  ^^• / mUU4S jmT" U / 5        / nT H²  nU VVVs/ s H  u  p4oT(       d  M  X4U4PM     nnnnU(       d  M/  [        U6 u  pxn	[        [        U6 5      n
[        [        U	6 5      nU Vs/ s H  n[        R                  " U5      PM     nnUS   n[        U
5       H  u  nnUR                  UUXß   45        M     M´     U$ s  snnnf s  snf )Nc                ó  >• UR                  U R                  U R                  U R                  45        U R                  (       d  TR                  US S  5        OU R                   H  nT" X!5        M     UR                  5         g r    )r¬   r¢   r¤   r€   r£   Úpop)Úcurrent_nodeÚcurrent_pathr£   ÚdfsÚpathss      €€r"   rè   Ú-_generate_paths_and_combinations.<locals>.dfs¢  si   ø€ Ø×Ñ˜\×-Ñ-¨|×/HÑ/HÈ,×J^ÑJ^Ð_Ô`à×!×!Ø�L‰L˜¡a˜Õ)à%×+Ô+�Ù�EÖ(ñ ,ð 	×ÑÕr%   rH   )rd   rV   r   rQ   Úprodrn   r¬   )r°   r_   Úpathr¢   ÚpermsrŠ   Úfiltered_pathÚ	node_keysr¤   r€   Úpath_combinationsÚweight_combinationsÚweight_tupleÚweight_productsr„   r�   Úcombinationrè   ré   s                    @@r"   r^   r^   Ÿ  sè   ù€ Ø€Eö	ñ ˆˆb„MàÐãˆÙHLÕVÊÑ2D°#¸fÓPUÓ-˜# fÓ-ÉˆÒVçˆ=Ü/2°MÐ/BÑ,ˆI WÜ $¤W¨lÐ%;Ó <ÐÜ"&¤w°Ð'8Ó"9ÐáI\Ó]ÒI\¸œrŸwšw |Ö4ÑI\ˆOÐ]à  ‘}ˆHÜ"+Ð,=Ö">‘��;Ø!×(Ñ(¨(°KÀÑASÐ)TÖUó #?ñ ð Ðùô Wùò ^s   ¢C
³C
Á9 Cc                óJ  • / nU  GH  u  p4n/ nU HD  n[        U[        5      (       a	  U(       d  M!  U H  nX�;   d  M
  UR                  X   5        M     MF     [        U5      S:”  aK  [	        U5      n	UR                  X9U45        X1;   a&  [	        XaU   /-   5      n
UR                  X:U45        M«  M­  [
        R                  " [        UR                  5       5      S   5      n	UR                  X9U45        X1;   d  M÷  [	        X‘U   /5      n
UR                  X:U45        GM     U$ r   )	rU   rW   r¬   r,   rÂ   rQ   Ú
zeros_likerV   rL   )r   re   Úcombined_masksr„   rô   r€   ra   rb   r¢   rÁ   Úcombined_mask_with_last_keys              r"   rf   rf   Â  s  € Ø€NÜ*6Ñ&ˆ˜wØˆÛˆDÜ˜$¤×&Ñ&®tÙÛ�ØÕ$Ø—L‘L ¡Ö1ó ñ  ô ˆu‹:˜‹>Ü*¨5Ó1ˆMØ×!Ñ! 8¸GÐ"DÔEàÓ%Ü.<¸UÐQYÑFZÐE[Ñ=[Ó.\Ð+Ø×%Ñ% xÈgÐ&VÖWñ &ô ŸMšM¬$¨z×/@Ñ/@Ó/BÓ*CÀAÑ*FÓGˆMØ×!Ñ! 8¸GÐ"DÔEàÕ%Ü.<¸mÐX`ÑMaÐ=bÓ.cÐ+Ø×%Ñ% xÈgÐ&V×Wñ- +7ð. Ðr%   c                óv  • [        U5       VVs0 s H  u  p#[        U5      U_M     nnn0 n0 n0 n[        U 5       Hr  u  nu  pšn[        U
5      nXL   nUS-  S:X  a5  X•;  a  / XY'   / Xy'   XY   R                  U5        Xy   R                  U5        MV  X–;  a  / Xi'   Xi   R                  U5        Mt     XVU4$ s  snnf )Nr   r   )rn   rW   r¬   )r÷   rl   r�   r{   Úunique_mask_index_mapr~   r   r€   r�   r„   rÁ   rŠ   Ú
mask_tupleÚunique_indexs                 r"   rm   rm   Þ  sÝ   € Ü?HÈÔ?VÔWÒ?V±)°#œU 4›[¨#Ò-Ñ?VÐÑWØ:<ÐØ9;ÐØ*,€Gä09¸.Ö0IÑ,ˆÑ,ˆH VÜ˜=Ó)ˆ
Ø,Ñ8ˆàˆq‰5�A‹:ØÓ6Ø46Ð'Ñ1Ø$&�Ñ!Ø#Ñ-×4Ñ4°\ÔBØÑ×$Ñ$ VÖ,àÓ5Ø35Ð&Ñ0Ø"Ñ,×3Ñ3°LÖAñ 1Jð #¸GÐCÐCùó) Xs   �B5) Ú
__future__r   rÅ   Ú	itertoolsr   r   r   ÚnumpyrQ   Ú r   Úexplainers._explainerr	   Úmodelsr
   Úutilsr   r   r   r   r[   r]   r½   rÂ   rÉ   rÒ   rÕ   r­   r`   r^   rf   rm   rK   r%   r"   Ú<module>r     sy   ðå "ã ß 2Ñ 2ã å Ý -Ý ß <Ñ <ôR6˜ô R6÷lVñ Vò!ò"'ò$ò
8ò\òòvò.ò8 òFó8Dr%   