Ë
    îÍ:j"x  ã                   ó  — d 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m	Z	m
Z
mZmZ ddlZddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" ddl#m$Z$ erdd	l%m&Z&  e!jN                  e(«      Z)ed
   Z* edd¬«      Z+ G d„ de«      Z, G d„ de«      Z- ee-j\                  «      e-_.        e-j\                  j                   �8e-j\                  j                   j_                  ddd¬«      e-j\                  _         yy)zH
Feature extraction saving/loading class for common feature extractors.
é    N)ÚUserDict)ÚTYPE_CHECKINGÚAnyÚOptionalÚTypeVarÚUnioné   )Úcustom_object_save)ÚFEATURE_EXTRACTOR_NAMEÚPROCESSOR_NAMEÚPushToHubMixinÚ
TensorTypeÚ	copy_funcÚdownload_urlÚis_flax_availableÚis_jax_tensorÚis_numpy_arrayÚis_offline_modeÚis_remote_urlÚis_tf_availableÚis_torch_availableÚis_torch_deviceÚis_torch_dtypeÚloggingÚrequires_backends)Úcached_file)ÚSequenceFeatureExtractorr   ÚSpecificFeatureExtractorTypeÚFeatureExtractionMixin)Úboundc                   ó¶   ‡ — e Zd ZdZddeeeef      dedee	f   fˆ fd„Z
dedefd„Zdefd	„Zd
„ Zd„ Zddeeee	f      fd„Zddeeee	f      fd„Zdd„Zˆ xZS )ÚBatchFeatureaU  
    Holds the output of the [`~SequenceFeatureExtractor.pad`] and feature extractor specific `__call__` methods.

    This class is derived from a python dictionary and can be used as a dictionary.

    Args:
        data (`dict`, *optional*):
            Dictionary of lists/arrays/tensors returned by the __call__/pad methods ('input_values', 'attention_mask',
            etc.).
        tensor_type (`Union[None, str, TensorType]`, *optional*):
            You can give a tensor_type here to convert the lists of integers in PyTorch/TensorFlow/Numpy Tensors at
            initialization.
    NÚdataÚtensor_typec                 óH   •— t         ‰| �  |«       | j                  |¬«       y )N)r$   )ÚsuperÚ__init__Úconvert_to_tensors)Úselfr#   r$   Ú	__class__s      €úz/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/transformers/feature_extraction_utils.pyr'   zBatchFeature.__init__M   s!   ø€ Ü‰Ñ˜ÔØ×Ñ¨KÐÕ8ó    ÚitemÚreturnc                 óV   — t        |t        «      r| j                  |   S t        d«      ‚)z�
        If the key is a string, returns the value of the dict associated to `key` ('input_values', 'attention_mask',
        etc.).
        zRIndexing with integers is not available when using Python based feature extractors)Ú
isinstanceÚstrr#   ÚKeyError©r)   r-   s     r+   Ú__getitem__zBatchFeature.__getitem__Q   s(   € ô
 �dœCÔ Ø—9‘9˜T‘?Ð"äÐoÓpÐpr,   c                 óH   — 	 | j                   |   S # t        $ r t        ‚w xY w©N)r#   r2   ÚAttributeErrorr3   s     r+   Ú__getattr__zBatchFeature.__getattr__[   s*   € ð	!Ø—9‘9˜T‘?Ð"øÜò 	!Ü Ð ð	!ús   ‚ ‘!c                 ó   — d| j                   iS ©Nr#   ©r#   ©r)   s    r+   Ú__getstate__zBatchFeature.__getstate__a   s   € Ø˜Ÿ	™	Ð"Ð"r,   c                 ó"   — d|v r|d   | _         y y r:   r;   )r)   Ústates     r+   Ú__setstate__zBatchFeature.__setstate__d   s   € Ø�U‰?Ø˜f™ˆD�Ið r,   c                 óP  ‡‡— |€yt        |t        «      st        |«      }|t        j                  k(  rJt        j	                  d«       t        «       st        d«      ‚dd l}|j                  Š|j                  }|‰fS |t        j                  k(  r.t        «       st        d«      ‚dd lŠˆfd„Š‰j                  }|‰fS |t        j                  k(  rFt        j	                  d«       t        «       st        d«      ‚dd lm} |j"                  Št$        }|‰fS d	ˆfd„	Št&        }|‰fS )
N©NNz¤TensorFlow and JAX classes are deprecated and will be removed in Transformers v5. We recommend migrating to PyTorch classes or pinning your version of Transformers.zSUnable to convert output to TensorFlow tensors format, TensorFlow is not installed.r   zMUnable to convert output to PyTorch tensors format, PyTorch is not installed.c                 óè  •— t        | t        t        f«      r t        | «      dkD  r’t        | d   t        j
                  «      rt	        j                  | «      } n_t        | d   t        t        f«      rFt        | d   «      dkD  r5t        | d   d   t        j
                  «      rt	        j                  | «      } t        | t        j
                  «      r‰j                  | «      S ‰j                  | «      S )Nr   )	r0   ÚlistÚtupleÚlenÚnpÚndarrayÚarrayÚ
from_numpyÚtensor)ÚvalueÚtorchs    €r+   Ú	as_tensorz5BatchFeature._get_is_as_tensor_fns.<locals>.as_tensorƒ   s­   ø€ Ü˜e¤d¬E ]Ô3¼¸E»
ÀQºÜ! %¨¡(¬B¯J©JÔ7Ü "§¡¨£™ä" 5¨¡8¬d´E¨]Ô;Ü  a¡›M¨AÒ-Ü& u¨Q¡x°¡{´B·J±JÔ?ä "§¡¨£˜Ü˜e¤R§Z¡ZÔ0Ø ×+Ñ+¨EÓ2Ð2à Ÿ<™<¨Ó.Ð.r,   zEUnable to convert output to JAX tensors format, JAX is not installed.c                 ó‚  •— t        | t        t        f«      rˆt        | d   t        t        t        j                  f«      r`| D �cg c]  }t        |«      ‘Œ }}t        t        |«      «      dkD  r1|€/ ‰| D �cg c]  }t        j                  |«      ‘Œ c}t        ¬«      } t        j                  | |¬«      S c c}w c c}w )Nr   r	   )Údtype)	r0   rD   rE   rG   rH   rF   ÚsetÚasarrayÚobject)rL   rP   ÚvalÚ
value_lensrN   s       €r+   rN   z5BatchFeature._get_is_as_tensor_fns.<locals>.as_tensor    s•   ø€ Ü˜e¤d¬E ]Ô3¼
À5ÈÁ8ÌdÔTYÔ[]×[eÑ[eÐMfÔ8gØ6;Ö!<¨s¤# c¥(Ð!<�JÐ!<Üœ3˜z›?Ó+¨aÒ/°E°Má )ÀeÖ*L¸s¬2¯:©:°c­?Ò*LÔTZÔ [˜Ü—z‘z %¨uÔ5Ð5ùò	 "=ùò +Ms   ÁB7Á7B<r6   )r0   r   Ú
TENSORFLOWÚloggerÚwarning_oncer   ÚImportErrorÚ
tensorflowÚconstantÚ	is_tensorÚPYTORCHr   rM   ÚJAXr   Ú	jax.numpyÚnumpyrI   r   r   )r)   r$   Útfr\   ÚjnprN   rM   s        @@r+   Ú_get_is_as_tensor_fnsz"BatchFeature._get_is_as_tensor_fnsh   s1  ù€ ØÐØô ˜+¤zÔ2Ü$ [Ó1ˆKð œ*×/Ñ/Ò/Ü×Ñðbôô #Ô$Ü!Øióð ó $àŸ™ˆIØŸ™ˆIðX ˜)Ð#Ð#ðW œJ×.Ñ.Ò.Ü%Ô'Ü!Ð"qÓrÐrÛô/ð Ÿ™ˆIð. ˜)Ð#Ð#ð- œJŸN™NÒ*Ü×Ñðbôô %Ô&Ü!Ð"iÓjÐjÝ#àŸ	™	ˆIÜ%ˆIð ˜)Ð#Ð#õ6ô 'ˆIØ˜)Ð#Ð#r,   c                 óÒ   — |€| S | j                  |«      \  }}| j                  «       D ]  \  }}	  ||«      s ||«      }|| |<   Œ | S #  |dk(  rt        d«      ‚t        d«      ‚xY w)a5  
        Convert the inner content to tensors.

        Args:
            tensor_type (`str` or [`~utils.TensorType`], *optional*):
                The type of tensors to use. If `str`, should be one of the values of the enum [`~utils.TensorType`]. If
                `None`, no modification is done.
        Úoverflowing_valueszKUnable to create tensor returning overflowing values of different lengths. zUnable to create tensor, you should probably activate padding with 'padding=True' to have batched tensors with the same length.)rc   ÚitemsÚ
ValueError)r)   r$   r\   rN   ÚkeyrL   rK   s          r+   r(   zBatchFeature.convert_to_tensors«   s–   € ð ÐØˆKà#×9Ñ9¸+ÓFÑˆ	�9ð Ÿ*™*›,ò 	‰JˆC�ðÙ  Ô'Ù& uÓ-�Fà &�D˜‘Iøð	ð ˆøðØÐ.Ò.Ü$Ð%rÓsÐsÜ ðXóð ús   °A	Á	A&c                 óÂ  ‡‡‡‡‡	— t        | dg«       ddlŠ	‰j                  d«      Š‰j                  dd«      Š‰€et        ‰«      dkD  rW‰d   }t	        |«      rnFt        |t        «      st        |«      st        |t        «      r|Šnt        dt        |«      › d�«      ‚ˆˆˆˆˆ	fd	„}| j                  «       D ��ci c]  \  }}| ||«      “Œ c}}| _        | S c c}}w )
a�  
        Send all values to device by calling `v.to(*args, **kwargs)` (PyTorch only). This should support casting in
        different `dtypes` and sending the `BatchFeature` to a different `device`.

        Args:
            args (`Tuple`):
                Will be passed to the `to(...)` function of the tensors.
            kwargs (`Dict`, *optional*):
                Will be passed to the `to(...)` function of the tensors.
                To enable asynchronous data transfer, set the `non_blocking` flag in `kwargs` (defaults to `False`).

        Returns:
            [`BatchFeature`]: The same instance after modification.
        rM   r   NÚdeviceÚnon_blockingFz*Attempting to cast a BatchFeature to type z. This is not supported.c                 óÐ   •— t        | ‰j                  «      r#‰j                  | «      r | j                  ‰i ‰¤ŽS t        | ‰j                  «      r‰�| j                  ‰‰¬«      S | S )N)rj   rk   )r0   ÚTensorÚis_floating_pointÚto)ÚvÚargsrj   Úkwargsrk   rM   s    €€€€€r+   Úmaybe_toz!BatchFeature.to.<locals>.maybe_toì   s_   ø€ ä˜!˜UŸ\™\Ô*¨u×/FÑ/FÀqÔ/Ià�q—t‘t˜TÐ, VÑ,Ð,Ü˜A˜uŸ|™|Ô,°Ð1CØ—t‘t 6¸�tÓEÐEà�r,   )r   rM   ÚgetrF   r   r0   r1   r   Úintrg   rf   r#   )
r)   rq   rr   Úargrs   Úkrp   rj   rk   rM   s
    ``    @@@r+   ro   zBatchFeature.toÊ   sÌ   ü€ ô 	˜$  	Ô*Ûà—‘˜HÓ%ˆØ—z‘z .°%Ó8ˆàˆ>œc $›i¨!šmà�q‘'ˆCÜ˜cÔ"àÜ˜C¤Ô%¬¸Ô)=ÄÈCÔQTÔAUØ‘ô !Ð#MÌcÐRUËhÈZÐWoÐ!pÓqÐq÷	ð 	ð 15·
±
³×=©¨¨1�Q™ ›‘^Ó=ˆŒ	Øˆùó >s   Â=CrB   r6   )r.   r"   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Údictr1   r   r   r   r'   r4   r8   r=   r@   rc   r(   ro   Ú__classcell__)r*   s   @r+   r"   r"   >   sŸ   ø„ ññ9˜X d¨3°¨8¡nÑ5ð 9È5ÐQUÐWZÐ\fÐQfÑKgõ 9ðq ð q¨ó qð! ó !ò#ò&ñA$°¸%ÀÀZÀÑ:PÑ1Qó A$ñF¨h°u¸SÀ*¸_Ñ7MÑ.Nó ÷>-r,   r"   c                   ó   — e Zd ZdZdZd„ Zdefd„Ze	 	 	 	 	 dde	e
   deeej                  f   deeeej                  f      d	ed
edeeeef      dede
fd„«       Zddeeej                  f   defd„Zedeeej                  f   deeeef   eeef   f   fd„«       Zedeeef   ded ed eeef   f   f   fd„«       Zdeeef   fd„Zedeeej                  f   dd fd„«       Zdefd„Zdeeej                  f   fd„Zd„ Zedd„«       Zy) r   zŠ
    This is a feature extraction mixin used to provide saving/loading functionality for sequential and image feature
    extractors.
    Nc           
      óà   — |j                  dd«      | _        |j                  «       D ]  \  }}	 t        | ||«       Œ y# t        $ r%}t
        j                  d|› d|› d| › �«       |‚d}~ww xY w)z'Set elements of `kwargs` as attributes.Úprocessor_classNz
Can't set z with value z for )ÚpopÚ_processor_classrf   Úsetattrr7   rW   Úerror)r)   rr   rh   rL   Úerrs        r+   r'   zFeatureExtractionMixin.__init__  sx   € ð !'§
¡
Ð+<¸dÓ CˆÔà Ÿ,™,›.ò 	‰JˆC�ðÜ˜˜c 5Õ)ñ	øô "ò Ü—‘˜z¨#¨¨l¸5¸'ÀÀtÀfÐMÔNØ�	ûðús   ¯?¿	A-Á A(Á(A-r€   c                 ó   — || _         y)z%Sets processor class as an attribute.N)r‚   )r)   r€   s     r+   Ú_set_processor_classz+FeatureExtractionMixin._set_processor_class  s
   € à /ˆÕr,   ÚclsÚpretrained_model_name_or_pathÚ	cache_dirÚforce_downloadÚlocal_files_onlyÚtokenÚrevisionr.   c                 ó  — ||d<   ||d<   ||d<   ||d<   |j                  dd«      }|�)t        j                  dt        «       |�t	        d«      ‚|}|�||d	<    | j
                  |fi |¤Ž\  }	} | j                  |	fi |¤ŽS )
a   
        Instantiate a type of [`~feature_extraction_utils.FeatureExtractionMixin`] from a feature extractor, *e.g.* a
        derived class of [`SequenceFeatureExtractor`].

        Args:
            pretrained_model_name_or_path (`str` or `os.PathLike`):
                This can be either:

                - a string, the *model id* of a pretrained feature_extractor hosted inside a model repo on
                  huggingface.co.
                - a path to a *directory* containing a feature extractor file saved using the
                  [`~feature_extraction_utils.FeatureExtractionMixin.save_pretrained`] method, e.g.,
                  `./my_model_directory/`.
                - a path or url to a saved feature extractor JSON *file*, e.g.,
                  `./my_model_directory/preprocessor_config.json`.
            cache_dir (`str` or `os.PathLike`, *optional*):
                Path to a directory in which a downloaded pretrained model feature extractor should be cached if the
                standard cache should not be used.
            force_download (`bool`, *optional*, defaults to `False`):
                Whether or not to force to (re-)download the feature extractor files and override the cached versions
                if they exist.
            resume_download:
                Deprecated and ignored. All downloads are now resumed by default when possible.
                Will be removed in v5 of Transformers.
            proxies (`dict[str, str]`, *optional*):
                A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
                'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
            token (`str` or `bool`, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, will use
                the token generated when running `hf auth login` (stored in `~/.huggingface`).
            revision (`str`, *optional*, defaults to `"main"`):
                The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
                git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
                identifier allowed by git.


                <Tip>

                To test a pull request you made on the Hub, you can pass `revision="refs/pr/<pr_number>"`.

                </Tip>

            return_unused_kwargs (`bool`, *optional*, defaults to `False`):
                If `False`, then this function returns just the final feature extractor object. If `True`, then this
                functions returns a `Tuple(feature_extractor, unused_kwargs)` where *unused_kwargs* is a dictionary
                consisting of the key/value pairs whose keys are not feature extractor attributes: i.e., the part of
                `kwargs` which has not been used to update `feature_extractor` and is otherwise ignored.
            kwargs (`dict[str, Any]`, *optional*):
                The values in kwargs of any keys which are feature extractor attributes will be used to override the
                loaded values. Behavior concerning key/value pairs whose keys are *not* feature extractor attributes is
                controlled by the `return_unused_kwargs` keyword parameter.

        Returns:
            A feature extractor of type [`~feature_extraction_utils.FeatureExtractionMixin`].

        Examples:

        ```python
        # We can't instantiate directly the base class *FeatureExtractionMixin* nor *SequenceFeatureExtractor* so let's show the examples on a
        # derived class: *Wav2Vec2FeatureExtractor*
        feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(
            "facebook/wav2vec2-base-960h"
        )  # Download feature_extraction_config from huggingface.co and cache.
        feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(
            "./test/saved_model/"
        )  # E.g. feature_extractor (or model) was saved using *save_pretrained('./test/saved_model/')*
        feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("./test/saved_model/preprocessor_config.json")
        feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(
            "facebook/wav2vec2-base-960h", return_attention_mask=False, foo=False
        )
        assert feature_extractor.return_attention_mask is False
        feature_extractor, unused_kwargs = Wav2Vec2FeatureExtractor.from_pretrained(
            "facebook/wav2vec2-base-960h", return_attention_mask=False, foo=False, return_unused_kwargs=True
        )
        assert feature_extractor.return_attention_mask is False
        assert unused_kwargs == {"foo": False}
        ```rŠ   r‹   rŒ   rŽ   Úuse_auth_tokenNúrThe `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.úV`token` and `use_auth_token` are both specified. Please set only the argument `token`.r�   )r�   ÚwarningsÚwarnÚFutureWarningrg   Úget_feature_extractor_dictÚ	from_dict)
rˆ   r‰   rŠ   r‹   rŒ   r�   rŽ   rr   r�   Úfeature_extractor_dicts
             r+   Úfrom_pretrainedz&FeatureExtractionMixin.from_pretrained  s¿   € ðp (ˆˆ{ÑØ#1ˆÐÑ Ø%5ˆÐ!Ñ"Ø%ˆˆzÑàŸ™Ð$4°dÓ;ˆØÐ%Ü�M‰Mð EÜôð Ð Ü Ølóð ð #ˆEàÐØ#ˆF�7‰Oà)G¨×)GÑ)GÐHeÑ)pÐioÑ)pÑ&Ð àˆs�}‰}Ð3Ñ>°vÑ>Ð>r,   Úsave_directoryÚpush_to_hubc           	      ó4  — |j                  dd«      }|�;t        j                  dt        «       |j	                  d«      �t        d«      ‚||d<   t        j                  j                  |«      rt        d|› d�«      ‚t        j                  |d¬	«       |rr|j                  d
d«      }|j                  d|j                  t        j                  j                  «      d   «      } | j                  |fi |¤Ž}| j                  |«      }| j                  �t!        | || ¬«       t        j                  j#                  |t$        «      }| j'                  |«       t(        j+                  d|› �«       |r%| j-                  ||j	                  d«      ¬«       |gS )az  
        Save a feature_extractor object to the directory `save_directory`, so that it can be re-loaded using the
        [`~feature_extraction_utils.FeatureExtractionMixin.from_pretrained`] class method.

        Args:
            save_directory (`str` or `os.PathLike`):
                Directory where the feature extractor JSON file will be saved (will be created if it does not exist).
            push_to_hub (`bool`, *optional*, defaults to `False`):
                Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
                repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
                namespace).
            kwargs (`dict[str, Any]`, *optional*):
                Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
        r�   Nr‘   r�   r’   zProvided path (z#) should be a directory, not a fileT)Úexist_okÚcommit_messageÚrepo_idéÿÿÿÿ)ÚconfigzFeature extractor saved in )rž   r�   )r�   r“   r”   r•   rt   rg   ÚosÚpathÚisfileÚAssertionErrorÚmakedirsÚsplitÚsepÚ_create_repoÚ_get_files_timestampsÚ_auto_classr
   Újoinr   Úto_json_filerW   ÚinfoÚ_upload_modified_files)	r)   rš   r›   rr   r�   rž   rŸ   Úfiles_timestampsÚoutput_feature_extractor_files	            r+   Úsave_pretrainedz&FeatureExtractionMixin.save_pretrained‚  s„  € ð  Ÿ™Ð$4°dÓ;ˆàÐ%Ü�M‰Mð EÜôð �z‰z˜'Ó"Ð.Ü Ølóð ð -ˆF�7‰Oä�7‰7�>‰>˜.Ô)Ü  ?°>Ð2BÐBeÐ!fÓgÐgä
�‰�N¨TÕ2áØ#ŸZ™ZÐ(8¸$Ó?ˆNØ—j‘j ¨N×,@Ñ,@ÄÇÁÇÁÓ,MÈbÑ,QÓRˆGØ'�d×'Ñ'¨Ñ:°6Ñ:ˆGØ#×9Ñ9¸.ÓIÐð ×ÑÐ'Ü˜t ^¸DÕAô )+¯©¯©°^ÔE[Ó(\Ð%à×ÑÐ7Ô8Ü�‰Ð1Ð2OÐ1PÐQÔRáØ×'Ñ'ØØØ Ø-Ø—j‘j Ó)ð (ô ð .Ð.Ð.r,   c                 óî  — |j                  dd«      }|j                  dd«      }|j                  dd«      }|j                  dd«      }|j                  dd«      }|j                  dd«      }|j                  d	d«      }	|j                  d
d«      }
|j                  dd«      }|	�)t        j                  dt        «       |�t	        d«      ‚|	}|j                  dd«      }|j                  dd«      }d|dœ}|�||d<   t        «       r|
st        j                  d«       d}
t        |«      }t        j                  j                  |«      }t        j                  j                  |«      r$t        j                  j                  |t        «      }t        j                  j                  |«      r|}d}nTt        |«      r|}t!        |«      }n;t        }	 |t"        fD �cg c]  }t%        |||||||
||||d¬«      x}	 �|‘Œ  }}|d   }	 t+        |d¬«      5 }|j-                  «       }ddd«       t/        j0                  «      }|j3                  d|«      }|rt        j                  d |› �«       ||fS t        j                  d › d!|› �«       ||fS c c}w # t&        $ r ‚ t(        $ r t'        d|› d|› dt        › d�«      ‚w xY w# 1 sw Y   Œ¡xY w# t.        j4                  $ r t'        d|› d�«      ‚w xY w)"a6  
        From a `pretrained_model_name_or_path`, resolve to a dictionary of parameters, to be used for instantiating a
        feature extractor of type [`~feature_extraction_utils.FeatureExtractionMixin`] using `from_dict`.

        Parameters:
            pretrained_model_name_or_path (`str` or `os.PathLike`):
                The identifier of the pre-trained checkpoint from which we want the dictionary of parameters.

        Returns:
            `tuple[Dict, Dict]`: The dictionary(ies) that will be used to instantiate the feature extractor object.
        rŠ   Nr‹   FÚresume_downloadÚproxiesÚ	subfolderr�   r�   rŒ   rŽ   r‘   r’   Ú_from_pipelineÚ
_from_autoúfeature extractor)Ú	file_typeÚfrom_auto_classÚusing_pipelinez+Offline mode: forcing local_files_only=TrueT)ÚfilenamerŠ   r‹   rµ   r´   rŒ   r¶   r�   Ú
user_agentrŽ   Ú%_raise_exceptions_for_missing_entriesr   z"Can't load feature extractor for 'zœ'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'z2' is the correct path to a directory containing a z fileúutf-8©ÚencodingÚfeature_extractorz"It looks like the config file at 'z' is not a valid JSON file.zloading configuration file z from cache at )r�   r“   r”   r•   rg   r   rW   r®   r1   r¢   r£   Úisdirr¬   r   r¤   r   r   r   r   ÚOSErrorÚ	ExceptionÚopenÚreadÚjsonÚloadsrt   ÚJSONDecodeError)rˆ   r‰   rr   rŠ   r‹   r´   rµ   r¶   r�   r�   rŒ   rŽ   Úfrom_pipeliner»   r¾   Úis_localÚfeature_extractor_fileÚresolved_feature_extractor_filer½   Úresolved_fileÚ resolved_feature_extractor_filesÚreaderÚtextr˜   s                           r+   r–   z1FeatureExtractionMixin.get_feature_extractor_dict¿  s^  € ð —J‘J˜{¨DÓ1ˆ	ØŸ™Ð$4°eÓ<ˆØ Ÿ*™*Ð%6¸Ó=ˆØ—*‘*˜Y¨Ó-ˆØ—J‘J˜{¨DÓ1ˆ	Ø—
‘
˜7 DÓ)ˆØŸ™Ð$4°dÓ;ˆØ!Ÿ:™:Ð&8¸%Ó@ÐØ—:‘:˜j¨$Ó/ˆàÐ%Ü�M‰Mð EÜôð Ð Ü Ølóð ð #ˆEàŸ
™
Ð#3°TÓ:ˆØ Ÿ*™* \°5Ó9ˆà#6È?Ñ[ˆ
ØÐ$Ø+8ˆJÐ'Ñ(äÔÑ%5Ü�K‰KÐEÔFØ#Ðä(+Ð,IÓ(JÐ%Ü—7‘7—=‘=Ð!>Ó?ˆÜ�7‰7�=‰=Ð6Ô7Ü%'§W¡W§\¡\Ð2OÔQgÓ%hÐ"Ü�7‰7�>‰>Ð7Ô8Ø.KÐ+Ø‰HÜÐ8Ô9Ø%BÐ"Ü.:Ð;XÓ.YÑ+ä%;Ð"ð#ð &<¼^Ð$Lö4à ä)4Ø9Ø%-Ø&/Ø+9Ø$+Ø,;Ø-=Ø&/Ø"'Ø'1Ø%-ØBGô*ð ˜ð  ð! ò "ð4Ð0ð 4ð* 3SÐSTÑ2UÐ/ð
	äÐ5ÀÔHð %ÈFØ—{‘{“}�÷%ä%)§Z¡Z°Ó%5Ð"Ø%;×%?Ñ%?Ð@SÐUkÓ%lÐ"ñ Ü�K‰KÐ5Ð6UÐ5VÐWÔXð & vÐ-Ð-ô	 �K‰KØ-Ð.DÐ-EÀ_ÐUtÐTuÐvôð & vÐ-Ð-ùòm4øô, ò ð Üò äØ8Ð9VÐ8Wð X9à9VÐ8Wð X/Ü/EÐ.FÀeðMóð ðú÷%ð %ûô
 ×#Ñ#ò 	ÜØ4Ð5TÐ4UÐUpÐqóð ð	úsB   Ç
J Ç#JÇ?J ÈK ÈKÈ%/K ÊJ Ê,KËKË
K Ë#K4r˜   c                 ó  — |j                  dd«      }g }|j                  «       D ]   \  }}||v sŒ|||<   |j                  |«       Œ" |D ]  }|j                  |d«       Œ  | di |¤Ž}t        j	                  d|› �«       |r||fS |S )a	  
        Instantiates a type of [`~feature_extraction_utils.FeatureExtractionMixin`] from a Python dictionary of
        parameters.

        Args:
            feature_extractor_dict (`dict[str, Any]`):
                Dictionary that will be used to instantiate the feature extractor object. Such a dictionary can be
                retrieved from a pretrained checkpoint by leveraging the
                [`~feature_extraction_utils.FeatureExtractionMixin.to_dict`] method.
            kwargs (`dict[str, Any]`):
                Additional parameters from which to initialize the feature extractor object.

        Returns:
            [`~feature_extraction_utils.FeatureExtractionMixin`]: The feature extractor object instantiated from those
            parameters.
        Úreturn_unused_kwargsFNzFeature extractor © )r�   rf   ÚappendrW   r®   )rˆ   r˜   rr   rÕ   Ú	to_removerh   rL   rÃ   s           r+   r—   z FeatureExtractionMixin.from_dict4  s²   € ð(  &Ÿz™zÐ*@À%ÓHÐð ˆ	Ø Ÿ,™,›.ò 	&‰JˆC�ØÐ,Ò,Ø.3Ð& sÑ+Ø× Ñ  Õ%ð	&ð ò 	"ˆCØ�J‰J�s˜DÕ!ð	"ñ  Ñ9Ð"8Ñ9Ðä�‰Ð(Ð):Ð(;Ð<Ô=ÙØ$ fÐ,Ð,à$Ð$r,   c                 ó’   — t        j                  | j                  «      }| j                  j                  |d<   d|v r|d= d|v r|d= |S )z´
        Serializes this instance to a Python dictionary. Returns:
            `dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
        Úfeature_extractor_typeÚmel_filtersÚwindow)ÚcopyÚdeepcopyÚ__dict__r*   rx   )r)   Úoutputs     r+   Úto_dictzFeatureExtractionMixin.to_dict[  sP   € ô
 —‘˜tŸ}™}Ó-ˆØ+/¯>©>×+BÑ+BˆÐ'Ñ(Ø˜FÑ"Ø�}Ð%Ø�vÑØ�xÐ Øˆr,   Ú	json_filec                 ó    — t        |d¬«      5 }|j                  «       }ddd«       t        j                  «      } | di |¤ŽS # 1 sw Y   Œ&xY w)aÞ  
        Instantiates a feature extractor of type [`~feature_extraction_utils.FeatureExtractionMixin`] from the path to
        a JSON file of parameters.

        Args:
            json_file (`str` or `os.PathLike`):
                Path to the JSON file containing the parameters.

        Returns:
            A feature extractor of type [`~feature_extraction_utils.FeatureExtractionMixin`]: The feature_extractor
            object instantiated from that JSON file.
        rÀ   rÁ   NrÖ   )rÇ   rÈ   rÉ   rÊ   )rˆ   râ   rÒ   rÓ   r˜   s        r+   Úfrom_json_filez%FeatureExtractionMixin.from_json_fileh  sN   € ô �) gÔ.ð 	!°&Ø—;‘;“=ˆD÷	!ä!%§¡¨DÓ!1ÐÙÑ,Ð+Ñ,Ð,÷	!ð 	!ús   ŽAÁAc                 ó  — | j                  «       }|j                  «       D ]3  \  }}t        |t        j                  «      sŒ!|j                  «       ||<   Œ5 |j                  dd«      }|�||d<   t        j                  |dd¬«      dz   S )zÃ
        Serializes this instance to a JSON string.

        Returns:
            `str`: String containing all the attributes that make up this feature_extractor instance in JSON format.
        r‚   Nr€   é   T)ÚindentÚ	sort_keysú
)	rá   rf   r0   rG   rH   Útolistr�   rÉ   Údumps)r)   Ú
dictionaryrh   rL   r‚   s        r+   Úto_json_stringz%FeatureExtractionMixin.to_json_string{  s…   € ð —\‘\“^ˆ
à$×*Ñ*Ó,ò 	1‰JˆC�Ü˜%¤§¡Õ,Ø"'§,¡,£.�
˜3’ð	1ð &Ÿ>™>Ð*<¸dÓCÐØÐ'Ø,<ˆJÐ(Ñ)ä�z‰z˜*¨Q¸$Ô?À$ÑFÐFr,   Újson_file_pathc                 óˆ   — t        |dd¬«      5 }|j                  | j                  «       «       ddd«       y# 1 sw Y   yxY w)zã
        Save this instance to a JSON file.

        Args:
            json_file_path (`str` or `os.PathLike`):
                Path to the JSON file in which this feature_extractor instance's parameters will be saved.
        ÚwrÀ   rÁ   N)rÇ   Úwriterí   )r)   rî   Úwriters      r+   r­   z#FeatureExtractionMixin.to_json_file�  s<   € ô �. #°Ô8ð 	0¸FØ�L‰L˜×,Ñ,Ó.Ô/÷	0÷ 	0ñ 	0ús	   � 8¸Ac                 óT   — | j                   j                  › d| j                  «       › �S )Nú )r*   rx   rí   r<   s    r+   Ú__repr__zFeatureExtractionMixin.__repr__›  s(   € Ø—.‘.×)Ñ)Ð*¨!¨D×,?Ñ,?Ó,AÐ+BÐCÐCr,   c                 ó�   — t        |t        «      s|j                  }ddlmc m} t        ||«      st        |› d�«      ‚|| _        y)a�  
        Register this class with a given auto class. This should only be used for custom feature extractors as the ones
        in the library are already mapped with `AutoFeatureExtractor`.



        Args:
            auto_class (`str` or `type`, *optional*, defaults to `"AutoFeatureExtractor"`):
                The auto class to register this new feature extractor with.
        r   Nz is not a valid auto class.)	r0   r1   rx   Útransformers.models.autoÚmodelsÚautoÚhasattrrg   r«   )rˆ   Ú
auto_classÚauto_modules      r+   Úregister_for_auto_classz.FeatureExtractionMixin.register_for_auto_classž  sC   € ô ˜*¤cÔ*Ø#×,Ñ,ˆJç6Ð6ä�{ JÔ/Ü 
˜|Ð+FÐGÓHÐHà$ˆ�r,   )NFFNÚmain)F)ÚAutoFeatureExtractor)rx   ry   rz   r{   r«   r'   r1   r‡   ÚclassmethodÚtyper   r   r¢   ÚPathLiker   Úboolr™   r²   rE   r|   r   r–   r—   rá   rä   rí   r­   rõ   rý   rÖ   r,   r+   r   r   ú   s  „ ñð
 €Kò
ð0°Có 0ð ð 8<Ø$Ø!&Ø,0Øñm?ØÐ.Ñ/ðm?à',¨S°"·+±+Ð-=Ñ'>ðm?ð ˜E # r§{¡{Ð"2Ñ3Ñ4ðm?ð ð	m?ð
 ðm?ð ˜˜c 4˜iÑ(Ñ)ðm?ð ðm?ð 
&òm?ó ðm?ñ^;/¨e°C¸¿¹Ð4DÑ.Eð ;/ÐTXó ;/ðz ðr.Ø,1°#°r·{±{Ð2BÑ,Cðr.à	ˆt�C˜�H‰~˜t C¨ H™~Ð-Ñ	.òr.ó ðr.ðh ð$%Ø%)¨#¨s¨(¡^ð$%à	Ð'¨Ð/GÈÈcÐSVÈhÉÐ/WÑ)XÐXÑ	Yò$%ó ð$%ðL˜˜c 3˜h™ó ð ð- u¨S°"·+±+Ð-=Ñ'>ð -ÐC[ò -ó ð-ð$G ó Gð*	0¨5°°b·k±kÐ1AÑ+Bó 	0òDð ò%ó ñ%r,   r¹   rÿ   zfeature extractor file)rS   Úobject_classÚobject_files)0r{   rÝ   rÉ   r¢   r“   Úcollectionsr   Útypingr   r   r   r   r   r`   rG   Údynamic_module_utilsr
   Úutilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Ú	utils.hubr   Ú!feature_extraction_sequence_utilsr   Ú
get_loggerrx   rW   ÚPreTrainedFeatureExtractorr   r"   r   r›   ÚformatrÖ   r,   r+   ú<module>r     sÿ   ðñó Û Û 	Û Ý  ß ?Õ ?ã å 4÷÷ ÷ ÷ õ õ& #ñ ÝKð 
ˆ×	Ñ	˜HÓ	%€à"Ð#=Ñ>Ð ñ  'Ð'EÐMeÔfÐ ôy�8ô yôxx%˜^ô x%ñv &/Ð/E×/QÑ/QÓ%RÐ Ô "Ø×%Ñ%×-Ñ-Ð9Ø1G×1SÑ1S×1[Ñ1[×1bÑ1bØ"Ð1GÐVnð 2có 2Ð×&Ñ&Õ.ð :r,   