Ë
    èÍ:j¤  ã                   ój   — 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mZ  G d„ de j                  «      Z
y)é    N)ÚOptional)ÚACCEPTED_MODEL_TYPESÚ	ModelSpecc                   óÊ   — e Zd ZdZedej                  dej                  fd„«       Zdej                  de	fd„Z
	 	 	 dde	d	ee	   d
ee	   dede	f
d„Zej                  d„ «       Zy)Ú	Converterz Base class for model converters.ÚparserÚreturnc                 ó°   — | j                  ddd¬«       | j                  ddd¬«       | j                  d	dt        d
¬«       | j                  ddd¬«       | S )z‡Adds common conversion options to the command line parser.

        Arguments:
          parser: Command line argument parser.
        z--output_dirTzOutput model directory.)ÚrequiredÚhelpz--vocab_mappingNz#Vocabulary mapping file (optional).)Údefaultr   z--quantizationzWeight quantization type.)r   Úchoicesr   z--forceÚ
store_truez=Force conversion even if the output directory already exists.)Úactionr   )Úadd_argumentr   )r   s    úu/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/ctranslate2/converters/converter.pyÚdeclare_argumentszConverter.declare_arguments   s‚   € ð 	×ÑØ TÐ0Ið 	ô 	
ð 	×ÑØ tÐ2Wð 	ô 	
ð 	×ÑØØÜ(Ø,ð	 	ô 	
ð 	×ÑØØØPð 	ô 	
ð
 ˆó    Úargsc                 ó|   — | j                  |j                  |j                  |j                  |j                  ¬«      S )a  Helper function to call :meth:`ctranslate2.converters.Converter.convert`
        with the parsed command line options.

        Arguments:
          args: Namespace containing parsed arguments.

        Returns:
          Path to the output directory.
        )ÚvmapÚquantizationÚforce)ÚconvertÚ
output_dirÚvocab_mappingr   r   )Úselfr   s     r   Úconvert_from_argszConverter.convert_from_args(   s:   € ð �|‰|Ø�O‰OØ×#Ñ#Ø×*Ñ*Ø—*‘*ð	 ó 
ð 	
r   Nr   r   r   r   c                 ó¼  — t         j                  j                  |«      r|st        d|z  «      ‚| j	                  «       }|€t        d«      ‚|�|j                  |«       |j                  «        |j                  |¬«       t         j                  j                  |«      rt        j                  |«       t        j                  |«       |j                  |«       |S )a)  Converts the model to the CTranslate2 format.

        Arguments:
          output_dir: Output directory where the CTranslate2 model is saved.
          vmap: Optional path to a vocabulary mapping file that will be included
            in the converted model directory.
          quantization: Weight quantization scheme (possible values are: int8, int8_float32,
            int8_float16, int8_bfloat16, int16, float16, bfloat16, float32).
          force: Override the output directory if it already exists.

        Returns:
          Path to the output directory.

        Raises:
          RuntimeError: If the output directory already exists and :obj:`force`
            is not set.
          NotImplementedError: If the converter cannot convert this model to the
            CTranslate2 format.
        z;output directory %s already exists, use --force to overridez<This model is not supported by CTranslate2 or this converter)r   )ÚosÚpathÚexistsÚRuntimeErrorÚ_loadÚNotImplementedErrorÚregister_vocabulary_mappingÚvalidateÚoptimizeÚshutilÚrmtreeÚmakedirsÚsave)r   r   r   r   r   Ú
model_specs         r   r   zConverter.convert9   sÀ   € ô4 �7‰7�>‰>˜*Ô%©eÜØMØñóð ð
 —Z‘Z“\ˆ
ØÐÜ%ØNóð ð ÐØ×2Ñ2°4Ô8à×ÑÔØ×Ñ¨ÐÔ6ô �7‰7�>‰>˜*Ô%Ü�M‰M˜*Ô%Ü
�‰�JÔØ�‰˜
Ô#ØÐr   c                 ó   — t        «       ‚)N)r%   )r   s    r   r$   zConverter._loadk   s   € ä!Ó#Ð#r   )NNF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstaticmethodÚargparseÚArgumentParserr   Ú	NamespaceÚstrr   r   Úboolr   ÚabcÚabstractmethodr$   © r   r   r   r      s­   „ Ù*àð (×"9Ñ"9ð ¸h×>UÑ>Uò ó ðð2
 h×&8Ñ&8ð 
¸Só 
ð( #Ø&*Øñ0àð0ð �s‰mð0ð ˜s‘mð	0ð
 ð0ð 
ó0ðd 	×Ññ$ó ñ$r   r   )r9   r4   r    r)   Útypingr   Úctranslate2.specs.model_specr   r   ÚABCr   r;   r   r   ú<module>r?      s)   ðÛ 
Û Û 	Û å ç Hôb$�—‘õ b$r   