ó
    >:ja4  ã                  ó.  • S SK Jr  S SKrS SKrS SK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  S SKrS SKJr  \(       a
  S SKJrJrJr  \R(                  " \5      rSS	 jr              SS
 jrSS jr     S               SS jjrg)é    )ÚannotationsN)ÚCallable)Úfnmatch)ÚPath)ÚTYPE_CHECKINGÚAny)Úlist_repo_files©ÚCrossEncoderÚSentenceTransformerÚSparseEncoderc                ó   ^ ^• SU U4S jjnU$ )zú
Wraps the save_pretrained method of a model to save to a subfolder.

Args:
    _save_pretrained_fn: The original save_pretrained function
    subfolder: The subfolder to save to

Returns:
    A wrapped function that saves to the specified subfolder
c                óp   >• [         R                  " [        U 5      T-  SS9  T" [        U 5      T-  40 UD6$ )NT)Úexist_ok)ÚosÚmakedirsr   )Úsave_directoryÚkwargsÚ_save_pretrained_fnÚ	subfolders     €€Ú`/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sentence_transformers/backend/utils.pyÚwrapperÚ)_save_pretrained_wrapper.<locals>.wrapper!   s5   ø€ Ü
�Š”D˜Ó(¨9Ñ4¸tÒDÙ"¤4¨Ó#7¸)Ñ#CÑNÀvÑNÐNó    )r   z
str | PathÚreturnÚNone© )r   r   r   s   `` r   Ú_save_pretrained_wrapperr      s   ù€ ÷Oð Oð €Nr   c                ó¦  • UR                  SS5      nU(       a  Xb4$ UR                  5       nUR                  SU5      nUR                  SS5      n	U	(       a  [        X˜5      R	                  5       O[        U5      R	                  5       n
U	(       a  [        X—U5      R	                  5       O[        Xx5      R	                  5       nU	(       a  U	 SU 3OSU 3nU(       a>  U R                  U5       Vs/ s H!  oÝR                  U 5      R	                  5       PM#     nnO_[        U R	                  5       SUR                  SS5      UR                  S	S5      S
9nU Vs/ s H  n[        UU5      (       d  M  UPM     nnX®;   nU(       d{  X¾;   nU(       ap  [        U5      S:”  a8  SU;  a2  [        R                  SU SU R	                  5       < SU SU< S3	5        U	(       a  [        X—5      R	                  5       OUUS'   X‚S'   Uc  U(       + n[        U5      R                  n[        U5      S:”  a8  US   US'   [        UR                  SS5      /USS Q76 R	                  5       US'   U(       aX  [        R                  SU< SU R	                  5       < SU S35        U(       a"  [        R                  SU SU SUS    S35        Xb4$ s  snf s  snf )aÌ  
Determines whether the model should be exported to the backend, or if it can be loaded directly.
Also update the `file_name` and `subfolder` model_kwargs if necessary.

These are the cases:

1. If export is set in model_kwargs, just return export
2. If `<subfolder>/<file_name>` exists; set export to False
3. If `<backend>/<file_name>` exists; set export to False and set subfolder to the backend (e.g. "onnx")
4. If `<file_name>` contains a folder, add those folders to the subfolder and set the file_name to the last part

We will warn if:

1. The expected file does not exist in the model directory given the optional file_name and subfolder.
    If there are valid files for this backend, but they're don't align with file_name, then we give a useful warning.
2. Multiple files are found in the model directory that match the target file name and the user did not
    specify the desired file name via `model_kwargs={"file_name": "<file_name>"}`

Args:
    load_path: The model repository or directory, as a Path instance
    is_local: Whether the model is local or remote, i.e. whether load_path is a local directory
    model_kwargs: The model_kwargs dictionary. Notable keys are "export", "file_name", and "subfolder"
    target_file_name: The expected file name in the model directory, e.g. "model.onnx" or "openvino_model.xml"
    target_file_glob: The glob pattern to match the target file name, e.g. "*.onnx" or "openvino*.xml"
    backend_name: The human-readable name of the backend for use in warnings, e.g. "ONNX" or "OpenVINO"

Returns:
    Tuple[bool, dict[str, Any]]: A tuple of the export boolean and the updated model_kwargs dictionary.
        Notable keys in model_kwargs are "export", "file_name", and "subfolder".
ÚexportNÚ	file_namer   z/**/z**/ÚmodelÚrevisionÚtoken)Ú	repo_typer#   r$   é   z	Multiple z files found in z: z, defaulting to zW. Please specify the desired file name via `model_kwargs={"file_name": "<file_name>"}`.éÿÿÿÿÚ zNo z
 found in z. Exporting the model to Ú.z#If you intended to load one of the Ú zN files, please specify the desired file name via `model_kwargs={"file_name": "r   z"}`.)ÚpopÚlowerÚgetr   Úas_posixÚglobÚrelative_tor	   r   ÚlenÚloggerÚwarningÚparts)Ú	load_pathÚis_localÚmodel_kwargsÚtarget_file_nameÚtarget_file_globÚbackend_namer    Úbackendr!   r   Úprimary_full_pathÚsecondary_full_pathÚglob_patternÚpathÚmodel_file_namesÚ	all_filesÚfnameÚmodel_foundÚfile_name_partss                      r   Úbackend_should_exportrE   (   sï  € ðL ×Ñ˜h¨Ó-€FÞØÐ#Ð#à× Ñ Ó"€GØ× Ñ  Ð.>Ó?€IØ× Ñ  ¨dÓ3€IÞAJœ˜YÓ2×;Ñ;Ô=ÔPTÐU^ÓP_×PhÑPhÓPjÐæ:CŒˆY Ó+×4Ñ4Ô6ÌÈgÓIa×IjÑIjÓIlð ö <E�i�[ Ð%5Ð$6Ñ7ÈCÐP`ÐOaÐJb€Lö ØOXÏ~É~Ð^jÔOkÓlÒOkÀt×,Ñ,¨YÓ7×@Ñ@ÖBÑOkÐÐlÐä#Ø×ÑÓ ØØ!×%Ñ% j°$Ó7Ø×"Ñ" 7¨DÓ1ñ	
ˆ	ñ 09ÓYªy e¼GÀEÈ<×<XŸE©yÐÐYð
 $Ñ7€KÞØ)Ñ=ˆÞÜÐ#Ó$ qÓ(¨[ÀÓ-LÜ—‘Ø ˜~Ð-=¸i×>PÑ>PÓ>RÑ=UÐUWÐXhÐWiÐiyð  {Nñ  zQð Qnð oôö PY¬¨YÓ(@×(IÑ(IÔ(KÐ^eˆL˜Ñ%Ø(1˜Ñ%Ø�~Ø ”ˆô ˜9“o×+Ñ+€OÜ
ˆ?Ó˜aÓØ$3°BÑ$7ˆ�[Ñ!Ü$(¨×)9Ñ)9¸+ÀrÓ)JÐ$bÈ_Ð]`Ð^`ÐMaÒ$b×$kÑ$kÓ$mˆ�[Ñ!æÜ�‰˜˜Y™M¨°I×4FÑ4FÓ4HÑ3KÐKdÐeqÐdrÐrsÐtÔuæÜ�N‰NØ5Ð6FÐ5GÀqÈÈð WZØZjÐklÑZmÐYnÐnsðuôð
 ÐÐùòU mùò Zs   Ã1(K	ÅKÅ3Kc                ór   • SU S3nU(       a  USU < S3-  nO
USU < S3-  n[         R                  U5        g)zØ
Warns the user to save the model if they just exported it.

Args:
    model_name_or_path: The model name or path
    is_local: Whether the model is local
    backend_name: The name of the backend (ONNX or OpenVINO)
zSaving the exported zA model is heavily recommended to avoid having to export it again.z# Do so with `model.save_pretrained(z)`.z Do so with `model.push_to_hub(z, create_pr=True)`.N)r2   r3   )Úmodel_name_or_pathr6   r:   Úto_logs       r   Úbackend_warn_to_saverI   Š   sO   € ð $ L >Ð1rÐs€FÞØÐ7Ð8JÑ7MÈSÐQÑQ‰àÐ3Ð4FÑ3IÐI\Ð]Ñ]ˆÜ
‡N�N�6Õr   c	                ól  • SSK Jn	Jn
Jn  US:X  a  SU S3nOUS:X  a  SU S3n[        R
                  " 5        nU " U5        US:X  af  [        U5      U-  n[        R                  " US	-  UW-  5        [        R                  " US
-  XÜ-  R                  S5      5        UR                  5       nUS:X  aW  [        U5      U-  nUR                  SSS9  [        U5      W-  nXì-  n[        R                  " UU5        UR                  5       nU(       aì  SnU(       aÁ  [        U5      R                  SS5      R                  SS5      R                  SS5      n[        X‹5      (       a  SU SW SU SU SU SU SU SU S3nOZUb  [        XŠ5      (       a  SU SW SU SU SU SU SU SU S3nO+[        X‰5      (       a  SU SW SU SU SU SU S U SU S3n[        R                   " UUUS!S"U S#W< 3UUS$9  Ož[        U5      U-  nUR                  SSS9  [        U5      W-  nXì-  n[        R"                  " UU5        US:X  aQ  [        U5      U-  R                  S5      n[        U5      U-  R                  S5      n[        R"                  " UU5        S S S 5        g ! , (       d  f       g = f)%Nr   r
   ÚonnxÚmodel_z.onnxÚopenvinoÚopenvino_model_z.xmlzopenvino_model.xmlzopenvino_model.binz.binT)Úparentsr   r(   Ú(z(
	z, z,
	Ú)z
)z+Hello!

This pull request adds an exported z	 model (`z`).

## Config
```python
a-  
```

## Testing this pull request
You can test this pull request before merging by loading the model from this PR with the `revision` argument:
```python
from sentence_transformers import SparseEncoder

# NOTE: Update this to the number of your pull request
pr_number = 2
model = SparseEncoder(
    "z5",
    revision=f"refs/pr/{pr_number}",
    backend="z#",
    model_kwargs={"file_name": "a5  "},
)

# Verify that everything works as expected
embeddings = model.encode(["The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium."])
print(embeddings.shape)

similarities = model.similarity(embeddings, embeddings)
print(similarities)
```

---
*This PR was auto-generated with [`zT`](https://sbert.net/docs/package_reference/util.html#sentence_transformers.backend.z).*
a9  
```

## Testing this pull request
You can test this pull request before merging by loading the model from this PR with the `revision` argument:
```python
from sentence_transformers import SentenceTransformer

# NOTE: Update this to the number of your pull request
pr_number = 2
model = SentenceTransformer(
    "a+  
```

## Testing this pull request
You can test this pull request before merging by loading the model from this PR with the `revision` argument:
```python
from sentence_transformers import CrossEncoder

# NOTE: Update this to the number of your pull request
pr_number = 2
model = CrossEncoder(
    "a2  "},
)

# Verify that everything works as expected
query = "Which planet is known as the Red Planet?"
passages = [
	"Venus is often called Earth's twin because of its similar size and proximity.",
	"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
	"Jupiter, the largest planet in our solar system, has a prominent red spot.",
	"Saturn, famous for its rings, is sometimes mistaken for the Red Planet."
]

scores = model.predict([(query, passage) for passage in passages])
print(scores)
```

---
*This PR was auto-generated with [`r"   zAdd exported z model )Úfolder_pathÚpath_in_repoÚrepo_idr%   Úcommit_messageÚcommit_descriptionÚ	create_pr)Úsentence_transformersr   r   r   ÚtempfileÚTemporaryDirectoryr   ÚshutilÚmoveÚwith_suffixr.   ÚmkdirÚreprÚreplaceÚ
isinstanceÚhuggingface_hubÚupload_folderÚcopy)Úexport_functionÚexport_function_nameÚconfigrG   Úpush_to_hubrW   Úfile_suffixr;   r"   r   r   r   r!   Úsave_dirÚdst_dirÚsourceÚdestinationrV   Úopt_config_stringÚ
bin_sourceÚbin_destinations                        r   Úsave_or_push_to_hub_modelrq   ›   s—  € ÷ WÑVà�&ÓØ˜[˜M¨Ð/‰	Ø	�JÓ	Ø% k ]°$Ð7ˆ	ä	×	$Ò	$Ô	&¨(Ù˜Ô!ð �jÓ Ü˜H“~¨Ñ/ˆHä�KŠK˜Ð#7Ñ7¸ÀIÑ9MÔNÜ�KŠK˜Ð#7Ñ7¸(Ñ:N×9[Ñ9[Ð\bÓ9cÔdØ×(Ñ(Ó*ˆHð �fÓÜ˜8“n wÑ.ˆGØ�M‰M $°ˆMÑ6Ü˜(“^ iÑ/ˆFØ!Ñ-ˆKÜ�KŠK˜ Ô,Ø×'Ñ'Ó)ˆHæØ!#ÐÞÜ$(¨£L×$8Ñ$8¸¸gÓ$F×$NÑ$NÈtÐU\Ó$]×$eÑ$eÐfiÐkpÓ$qÐ!Ü˜e×3Ñ3ð.$ð %, 9¨I°i°[ð Að Ð ð ð Ðð àˆYð "Ø"+ ð -$ð %9Ð#9ð  :Nð  Ocð  Ndð dðC"*Ñ&ðF ‘]¤j°×&LÑ&Lð.$ð %, 9¨I°i°[ð Að Ð ð ð Ðð àˆYð "Ø"+ ð -$ð %9Ð#9ð  :Nð  Ocð  Ndð dðC"*Ñ&ôF   ×4Ñ4ð.$ð %, 9¨I°i°[ð Að Ð ð ð Ðð àˆYð "Ø"+ ð -$ð" %9Ð#9ð  :Nð  Ocð  Ndð dðM'*Ð&ôR ×)Ò)Ø$Ø$Ø*Ø!Ø!.¨w¨i°w¸y¹mÐLØ#5Ø#óô Ð-Ó.°Ñ8ˆGà�M‰M $°ˆMÑ6ä˜(“^ iÑ/ˆFØ!Ñ-ˆKÜ�KŠK˜ Ô,ð ˜*Ó$Ü" 8›n¨yÑ8×EÑEÀfÓM�
Ü#'¨£=°9Ñ#<×"IÑ"IÈ&Ó"Q�Ü—’˜J¨Ô8÷E 
'×	&Ö	&ús   ¹I#J%Ê%
J3)r   r   r   Ústrr   zCallable[..., None])r5   r   r6   Úboolr7   zdict[str, Any]r8   rr   r9   rr   r:   rr   r   ztuple[bool, dict[str, Any]])rG   rr   r6   rs   r:   rr   r   r   )FFNrK   N)re   r   rf   rr   rG   rr   rh   rs   rW   rs   ri   z
str | Noner;   rr   r"   z9SentenceTransformer | SparseEncoder | CrossEncoder | None)Ú
__future__r   Úloggingr   r[   rY   Úcollections.abcr   r   Úpathlibr   Útypingr   r   rb   r	   rX   r   r   r   Ú	getLoggerÚ__name__r2   r   rE   rI   rq   r   r   r   Ú<module>r{      s  ðÝ "ã Û 	Û Û Ý $Ý Ý ß %ã Ý +æßVÑVà	×	Ò	˜8Ó	$€ôð&_ Øð_ àð_ ð !ð_ ð ð	_ ð
 ð_ ð ð_ ð !ô_ ôDð, ØØ"ØØGKðt9Øðt9àðt9ð ð	t9ð
 ðt9ð ðt9ð ðt9ð ðt9ð Eöt9r   