
    bi	                        d dl mZ d dlZd dlZd dlZd dlmZ ddZdd	Zed
             Z	eej
        fd            Zd ZdS )    )annotationsN)contextmanagerreturnstrc                    | j         j        }||t          j         j        k    r| j         j        S |dz   | j         j        z   S )a  
    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:
        o: The object for which to get the full name.

    Returns:
        str: The full name of the object.

    Example:
        >>> from sentence_transformers.losses import MultipleNegativesRankingLoss
        >>> from sentence_transformers import SentenceTransformer
        >>> from sentence_transformers.util import fullname
        >>> model = SentenceTransformer('all-MiniLM-L6-v2')
        >>> loss = MultipleNegativesRankingLoss(model)
        >>> fullname(loss)
        'sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss'
    N.)	__class__
__module__r   __name__)omodules     Z/root/projects/butler/venv/lib/python3.11/site-packages/sentence_transformers/util/misc.pyfullnamer   	   sA    * [#F~3=#;;;{##|ak222    dotted_pathtypec                ^   	 |                      dd          \  }}n"# t          $ r |  d}t          |          w xY w	 t          j        |           }n$# t
          $ r t          j        |          }Y nw xY w	 t          ||          S # 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.losses.MultipleNegativesRankingLoss')
        <class 'sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss'>
    r      z  doesn't look like a module pathzModule "z" does not define a "z" attribute/class)rsplit
ValueErrorImportError	importlibimport_module	ExceptiongetattrAttributeError)r   module_path
class_namemsgr   s        r   import_from_stringr    %   s    $"-"4"4S!"<"<ZZ   >>>#6(55 6 6 6(556vz***   XXX:XXX#s%    ;A A54A59B	 	#B,c               #     K   ddl m} m}m}  |            }	 |r
 |              dV  |r |             dS dS # |r |             w w xY 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_cachingr'   I   s      
 MLLLLLLLLL..00  	O  	N	 	  	N	s	   8 Ac              #     K   t           j        j        j        }t          j        |            	 dV  t          j        |           dS # t          j        |           w xY 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_loggingr/   [   s_       \)1NOM"""('''''''''s   A Ac                   t          | dd          5 }t          j        |          }t          |          }d d d            n# 1 swxY w Y   t	          |          dk    rq|d                             |           t          | ddd          5 }t          j        |          }|                    |           d d d            n# 1 swxY w Y   dS dS )	N zutf-8)newlineencodingr   wTF)opencsvreaderlistlenextendwriter	writerows)csv_pathadditional_datafr8   rowsr<   s         r   append_to_last_rowrB   m   s@   	hW	5	5	5 AF||               4yy1}}R((( (Cg>>> 	#!Z]]FT"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# t5s#   $AA
A*CC	C	)r   r   )r   r   r   r   )
__future__r   r7   r   r)   
contextlibr   r   r    r'   CRITICALr/   rB    r   r   <module>rG      s    " " " " " " 



      % % % % % %3 3 3 38! ! ! !H   " ")"2 ( ( ( ("    r   