
    BNj])                        d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 ddZddZ	 dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Zed
        Zeej                  fd       Zd Zg dZy)    )annotationsN)contextmanager)isclassc                    t        |       s| j                  } | j                  }||t        j                  j                  k(  r| j                  S |dz   | j                  z   S )aI  
    Gives a full name (package_name.class_name) for a class / object in Python. Will
    be used to load the correct classes from JSON files

    Args:
        obj: The object for which to get the full name, e.g. an instance of a class or the class itself.

    Returns:
        str: The full name of the object.

    Example:
        >>> from sentence_transformers.sentence_transformer.losses import MultipleNegativesRankingLoss
        >>> from sentence_transformers import SentenceTransformer
        >>> from sentence_transformers.util import fullname
        >>> model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
        >>> loss = MultipleNegativesRankingLoss(model)
        >>> fullname(loss)
        'sentence_transformers.sentence_transformer.losses.multiple_negatives_ranking.MultipleNegativesRankingLoss'
    .)r   	__class__
__module__str__name__)objmodules     p/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/sentence_transformers/util/misc.pyfullnamer      sP    ( 3<mm^^F~3==#;#;;||C<#,,&&    c                   	 | j                  dd      \  }}t        j                         5  t        j
                  dt               	 t        j                  |       }ddd       	 t        |      S # t        $ r |  d}t        |      w xY w# t        $ r t        j                  |      }Y Rw xY w# 1 sw Y   WxY w# t        $ r d| d| d}t        |      w xY w)	a}  
    Import a dotted module path and return the attribute/class designated by the
    last name in the path. Raise ImportError if the import failed.

    Args:
        dotted_path (str): The dotted module path.

    Returns:
        Any: The attribute/class designated by the last name in the path.

    Raises:
        ImportError: If the import failed.

    Example:
        >>> import_from_string('sentence_transformers.sentence_transformer.losses.multiple_negatives_ranking.MultipleNegativesRankingLoss')
        <class 'sentence_transformers.sentence_transformer.losses.multiple_negatives_ranking.MultipleNegativesRankingLoss'>
    r      z  doesn't look like a module pathignoreNzModule "z" does not define a "z" attribute/class)rsplit
ValueErrorImportErrorwarningscatch_warningssimplefilterDeprecationWarning	importlibimport_module	ExceptiongetattrAttributeError)dotted_pathmodule_path
class_namemsgr   s        r   import_from_stringr$   (   s    $"-"4"4S!"<Z 
	 	 	"h(:;	:,,[9F 
#vz**  =>#  	:,,[9F	:	 
#	"  %::,FWX#s@   A1 B2B%B> 1BB/,B2.B//B22B;>CF)trust_remote_coderevisioncode_revisiontokencache_folderlocal_files_onlyc          	     N   | j                  d      rt        |       S |^|st        j                  j	                  |      r=ddlm} 	  || ||||||      }	|s#t        j                  d| d|dt        d	       |	S t        |       S # t        t        f$ r Y t        |       S w xY w)
a[  
    Resolve a module class reference to a class object.

    For class refs in the ``sentence_transformers.*`` namespace, this imports directly via
    :func:`import_from_string`. For other class refs (e.g. repository-local custom classes
    like ``modeling_my_model.CustomTransformer``), it first tries
    :func:`transformers.dynamic_module_utils.get_class_from_dynamic_module` to fetch the
    modeling file from the model directory, then falls back to :func:`import_from_string`
    if dynamic loading is not applicable or fails.

    Dynamic loading is attempted when ``trust_remote_code`` is set, or when
    ``model_name_or_path`` resolves to a local directory (i.e. the user already has the
    file on disk and is implicitly trusted).

    .. deprecated:: 5.6
        The implicit trust of local directories is deprecated and will be removed in v6.0.
        From v6.0, loading repository-local custom code will require ``trust_remote_code=True``,
        matching the behavior for models loaded from the Hugging Face Hub. A ``FutureWarning`` is
        emitted whenever a local model is loaded via this short-circuit without
        ``trust_remote_code=True``.

    Args:
        class_ref: Dotted class path. Either a fully-qualified ``sentence_transformers.*``
            path or a repository-local reference like ``modeling_<name>.<ClassName>``.
        model_name_or_path: Hub repo id or local directory used to source repository-local
            modeling files. Required for dynamic loading.
        trust_remote_code: Whether to permit dynamic loading from an unverified Hub repo.
        revision: Hub revision to fetch the modeling file from.
        code_revision: Optional separate revision pinning for the modeling code (overrides
            ``revision`` when set).
        token: Hugging Face Hub authentication token. Required for fetching modeling files
            from private repositories.
        cache_folder: Optional override for the Hugging Face Hub cache directory.
        local_files_only: If True, only use cached files and never reach out to the Hub.

    Returns:
        The resolved class.
    zsentence_transformers.r   )get_class_from_dynamic_module)r&   r'   r(   	cache_dirr*   zLoading custom module z from local path zz without `trust_remote_code=True` is deprecated. It will require `trust_remote_code=True` from Sentence Transformers v6.0.   )
stacklevel)
startswithr$   ospathexists!transformers.dynamic_module_utilsr,   r   warnFutureWarningOSErrorr   )
	class_refmodel_name_or_pathr%   r&   r'   r(   r)   r*   r,   module_classs
             r   import_module_classr;   O   s    b 45!),,%+<Oa@bS	 8"!+&!1L %,YM9JK]J` a2 3 "   i((! $ 	 i((!	s   B B$#B$c               #  |   K   ddl m} m}m}  |       }	 |r |         d |r |        yy# |r |        w w xY ww)zN
    A context manager that will disable caching in the datasets library.
    r   )disable_cachingenable_cachingis_caching_enabledN)datasetsr=   r>   r?   )r=   r>   r?   is_originally_enableds       r   disable_datasets_cachingrB      sF     
 ML.0   !  !s   <- <9<c              #     K   t         j                  j                  j                  }t        j                  |        	 d t        j                  |       y# t        j                  |       w xY ww)z
    A context manager that will prevent any logging messages
    triggered during the body from being processed.

    Args:
        highest_level: the maximum logging level allowed.
    N)loggingrootmanagerdisable)highest_levelprevious_levels     r   disable_loggingrJ      sI      \\))11NOOM"(''s   :A1A A1A..A1c                d   t        | dd      5 }t        j                  |      }t        |      }d d d        t	              dkD  rS|d   j                  |       t        | ddd      5 }t        j                  |      }|j                  |       d d d        yy# 1 sw Y   kxY w# 1 sw Y   yxY w)	N zutf-8)newlineencodingr   wTF)opencsvreaderlistlenextendwriter	writerows)csv_pathadditional_datafrS   rowsrW   s         r   append_to_last_rowr]      s    	hW	5AF| 
6 4y1}R( (Cg>!ZZ]FT" ?  
6	5 ? s   !B)'B&B#&B/)Dzalbert-base-v1zalbert-base-v2zalbert-large-v1zalbert-large-v2zalbert-xlarge-v1zalbert-xlarge-v2zalbert-xxlarge-v1zalbert-xxlarge-v2zbert-base-cased-finetuned-mrpczbert-base-casedzbert-base-chinesezbert-base-german-casedzbert-base-german-dbmdz-casedzbert-base-german-dbmdz-uncasedzbert-base-multilingual-casedzbert-base-multilingual-uncasedzbert-base-uncasedz3bert-large-cased-whole-word-masking-finetuned-squadz#bert-large-cased-whole-word-maskingzbert-large-casedz5bert-large-uncased-whole-word-masking-finetuned-squadz%bert-large-uncased-whole-word-maskingzbert-large-uncasedzcamembert-basectrlz%distilbert-base-cased-distilled-squadzdistilbert-base-casedzdistilbert-base-german-casedz"distilbert-base-multilingual-casedz'distilbert-base-uncased-distilled-squadz/distilbert-base-uncased-finetuned-sst-2-englishzdistilbert-base-uncased
distilgpt2zdistilroberta-basez
gpt2-largezgpt2-mediumzgpt2-xlgpt2z
openai-gptzroberta-base-openai-detectorzroberta-basezroberta-large-mnlizroberta-large-openai-detectorzroberta-largezt5-11bzt5-3bzt5-basezt5-largezt5-smallztransfo-xl-wt103zxlm-clm-ende-1024zxlm-clm-enfr-1024zxlm-mlm-100-1280zxlm-mlm-17-1280zxlm-mlm-en-2048zxlm-mlm-ende-1024zxlm-mlm-enfr-1024zxlm-mlm-enro-1024zxlm-mlm-tlm-xnli15-1024zxlm-mlm-xnli15-1024zxlm-roberta-basez)xlm-roberta-large-finetuned-conll02-dutchz+xlm-roberta-large-finetuned-conll02-spanishz+xlm-roberta-large-finetuned-conll03-englishz*xlm-roberta-large-finetuned-conll03-germanzxlm-roberta-largezxlnet-base-casedzxlnet-large-cased)returnr
   )r    r
   ra   type)N)r8   r
   r9   
str | Noner%   boolr&   rc   r'   rc   r(   zbool | str | Noner)   rc   r*   rd   ra   rb   )
__future__r   rR   r   rD   r1   r   
contextlibr   inspectr   r   r$   r;   rB   CRITICALrJ   r]   ORIGINAL_TRANSFORMER_MODELS r   r   <module>rk      s    " 
   	  % '8$R &*Q) $ $##"Q)Q)"Q) 	Q)
 Q) Q) Q) Q) Q) 
Q)h  " ")"2"2 ( ("(E r   