Ë
    l^(hà	  ã                  óZ   — d Z ddlmZ ddlZddlmZ ddlmZm	Z	 ddl
mZ  G d„ de«      Zy)	a›  
This file contains deprecated code that can only be used with the old `model.fit`-style Sentence Transformers v2.X training.
It exists for backwards compatibility with the `model.old_fit` method, but will be removed in a future version.

Nowadays, with Sentence Transformers v3+, it is recommended to use the `SentenceTransformerTrainer` class to train models.
See https://www.sbert.net/docs/sentence_transformer/training_overview.html for more information.

See this script for more details on how to use the new training API:
https://github.com/UKPLab/sentence-transformers/blob/master/examples/sentence_transformer/unsupervised_learning/TSDAE/train_stsb_tsdae.py
é    )ÚannotationsN)ÚDataset)ÚNLTK_IMPORT_ERRORÚis_nltk_available)ÚInputExamplec                  ó<   — e Zd ZdZd„ fdd„Zd„ Zd„ Zed	d„«       Zy)
ÚDenoisingAutoEncoderDatasetaŸ  
    The DenoisingAutoEncoderDataset returns InputExamples in the format: texts=[noise_fn(sentence), sentence]
    It is used in combination with the DenoisingAutoEncoderLoss: Here, a decoder tries to re-construct the
    sentence without noise.

    Args:
        sentences: A list of sentences
        noise_fn: A noise function: Given a string, it returns a string
            with noise, e.g. deleted words
    c                ó,   — t         j                  | «      S ©N)r	   Údelete)Úss    úx/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sentence_transformers/datasets/DenoisingAutoEncoderDataset.pyú<lambda>z$DenoisingAutoEncoderDataset.<lambda>!   s   € Ô@[×@bÑ@bÐcdÓ@e€ ó    c                ó˜   — t        «       s2t        t        j                  | j                  j
                  «      «      ‚|| _        || _        y r   )r   ÚImportErrorr   ÚformatÚ	__class__Ú__name__Ú	sentencesÚnoise_fn)Úselfr   r   s      r   Ú__init__z$DenoisingAutoEncoderDataset.__init__!   s7   € Ü Ô"ÜÔ/×6Ñ6°t·~±~×7NÑ7NÓOÓPÐPà"ˆŒØ ˆ�r   c                óZ   — | j                   |   }t        | j                  |«      |g¬«      S )N)Útexts)r   r   r   )r   ÚitemÚsents      r   Ú__getitem__z'DenoisingAutoEncoderDataset.__getitem__(   s)   € Ø�~‰~˜dÑ#ˆÜ 4§=¡=°Ó#6¸Ð"=Ô>Ð>r   c                ó,   — t        | j                  «      S r   )Úlenr   )r   s    r   Ú__len__z#DenoisingAutoEncoderDataset.__len__,   s   € Ü�4—>‘>Ó"Ð"r   c                óN  — ddl m} ddlm}  || «      }t	        |«      }|dk(  r| S t
        j                  j                  |«      |kD  }t        |«      dk(  r"d|t
        j                  j                  |«      <    |«       j                  t        j                  |«      |   «      }|S )Nr   )Úword_tokenize)ÚTreebankWordDetokenizerT)Únltkr#   Únltk.tokenize.treebankr$   r    ÚnpÚrandomÚrandÚsumÚchoiceÚ
detokenizeÚarray)ÚtextÚ	del_ratior#   r$   ÚwordsÚnÚkeep_or_notÚwords_processeds           r   r   z"DenoisingAutoEncoderDataset.delete0   sŠ   € å&ÝBá˜dÓ#ˆÜ�‹JˆØ�Š6ØˆKä—i‘i—n‘n QÓ'¨)Ñ3ˆÜˆ{Ó˜qÒ Ø/3ˆKœŸ	™	×(Ñ(¨Ó+Ñ,Ù1Ó3×>Ñ>¼r¿x¹xÈ»È{Ñ?[Ó\ˆØÐr   N)r   z	list[str])g333333ã?)	r   Ú
__module__Ú__qualname__Ú__doc__r   r   r!   Ústaticmethodr   © r   r   r	   r	      s0   „ ñ	ñ 7fô !ò?ò#ð òó ñr   r	   )r6   Ú
__future__r   Únumpyr'   Útorch.utils.datar   Útransformers.utils.import_utilsr   r   Ú*sentence_transformers.readers.InputExampler   r	   r8   r   r   ú<module>r>      s'   ðñ	õ #ã Ý $ß På Cô) 'õ )r   