§
    [zni4s  ã                   óà  — 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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#m$Z$ er e ¦   «         rddl%Z% e#j&        e'¦  «        Z(ed         Z) G d	„ d
e¦  «        Z* G d„ de¦  «        Z+ ee+j,        ¦  «        e+_,        e+j,        j         �.e+j,        j          -                    ddd¬¦  «        e+j,        _         dS dS )zI
 Feature extraction saving/loading class for common feature extractors.
é    N)ÚUserDict)ÚTYPE_CHECKINGÚAnyÚDictÚOptionalÚTupleÚUnioné   )Úcustom_object_save)ÚFEATURE_EXTRACTOR_NAMEÚPushToHubMixinÚ
TensorTypeÚadd_model_info_to_auto_mapÚcached_fileÚ	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ÚSequenceFeatureExtractorc                   óþ   ‡ — 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e         fd„Zdefd	„Zd
„ Zd„ Z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                 óv   •— t          ¦   «                              |¦  «         |                      |¬¦  «         d S )N)r"   )ÚsuperÚ__init__Úconvert_to_tensors)Úselfr!   r"   Ú	__class__s      €ú…/var/www/html/cool-property-finder/image-detection-backend/venv/lib/python3.11/site-packages/transformers/feature_extraction_utils.pyr%   zBatchFeature.__init__L   s8   ø€ Ý‰Œ×Ò˜ÑÔÐØ×Ò¨KÐÑ8Ô8Ð8Ð8Ð8ó    ÚitemÚreturnc                 ód   — 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__P   s2   € õ
 �d�CÑ Ô ð 	qØ”9˜T”?Ð"åÐoÑpÔpÐpr*   c                 óH   — 	 | j         |         S # t          $ r t          ‚w xY w©N)r!   r0   ÚAttributeErrorr1   s     r)   Ú__getattr__zBatchFeature.__getattr__Z   s4   € ð	!Ø”9˜T”?Ð"øÝð 	!ð 	!ð 	!Ý Ð ð	!øøøs   ‚ �!c                 ó   — d| j         iS ©Nr!   ©r!   ©r'   s    r)   Ú__getstate__zBatchFeature.__getstate__`   s   € Ø˜œ	Ð"Ð"r*   c                 ó,   — d|v r|d         | _         d S d S r8   r9   )r'   Ústates     r)   Ú__setstate__zBatchFeature.__setstate__c   s!   € Ø�Uˆ?ˆ?Ø˜fœˆDŒIˆIˆIð ˆ?r*   c                 ó4   — | j                              ¦   «         S r4   )r!   Úkeysr:   s    r)   r@   zBatchFeature.keysh   s   € ØŒy�~Š~ÑÔÐr*   c                 ó4   — | j                              ¦   «         S r4   )r!   Úvaluesr:   s    r)   rB   zBatchFeature.valuesl   s   € ØŒy×ÒÑ!Ô!Ð!r*   c                 ó4   — | j                              ¦   «         S r4   )r!   Úitemsr:   s    r)   rD   zBatchFeature.itemsp   s   € ØŒy�ŠÑ Ô Ð r*   c                 óø  ‡‡— |€dS t          |t          ¦  «        st          |¦  «        }|t          j        k    r0t          ¦   «         st	          d¦  «        ‚dd l}|j        Š|j        }n�|t          j        k    r.t          ¦   «         st	          d¦  «        ‚dd l
Šˆfd„Š‰j        }nO|t          j        k    r2t          ¦   «         st	          d¦  «        ‚dd lm} |j        Št           }ndˆfd„	Št"          }|‰fS )	N©NNzSUnable 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¦  «        rGt          | ¦  «        dk    r4t          | d         t          j        ¦  «        rt	          j        | ¦  «        }  ‰j        | ¦  «        S )Nr   )r.   ÚlistÚtupleÚlenÚnpÚndarrayÚarrayÚtensor)ÚvalueÚtorchs    €r)   Ú	as_tensorz5BatchFeature._get_is_as_tensor_fns.<locals>.as_tensorŠ   s_   ø€ Ý˜e¥d­E ]Ñ3Ô3ð ,½¸E¹
¼
ÀQº¸Í:ÐV[Ð\]ÔV^Õ`bÔ`jÑKkÔKk¸ÝœH U™OœO�EØ#�u”| EÑ*Ô*Ð*r*   zEUnable to convert output to JAX tensors format, JAX is not installed.c                 óV  •— t          | t          t          f¦  «        rwt          | d         t          t          t          j        f¦  «        rJd„ | D ¦   «         }t          t          |¦  «        ¦  «        dk    r|€ ‰d„ | D ¦   «         t          ¬¦  «        } t          j        | |¬¦  «        S )Nr   c                 ó,   — g | ]}t          |¦  «        ‘ŒS © )rJ   ©Ú.0Úvals     r)   ú
<listcomp>zIBatchFeature._get_is_as_tensor_fns.<locals>.as_tensor.<locals>.<listcomp>›   s   € Ð!<Ð!<Ð!<¨s¥# c¡(¤(Ð!<Ð!<Ð!<r*   r
   c                 ó6   — g | ]}t          j        |¦  «        ‘ŒS rT   )rK   ÚasarrayrU   s     r)   rX   zIBatchFeature._get_is_as_tensor_fns.<locals>.as_tensor.<locals>.<listcomp>ž   s    € Ð*LÐ*LÐ*L¸s­2¬:°c©?¬?Ð*LÐ*LÐ*Lr*   )Údtype)	r.   rH   rI   rK   rL   rJ   ÚsetÚobjectrZ   )rO   r[   Ú
value_lensrQ   s      €r)   rQ   z5BatchFeature._get_is_as_tensor_fns.<locals>.as_tensor™   s¥   ø€ Ý˜e¥d­E ]Ñ3Ô3ð \½
À5ÈÄ8ÍdÕTYÕ[]Ô[eÐMfÑ8gÔ8gð \Ø!<Ð!<°eÐ!<Ñ!<Ô!<�JÝ�3˜z™?œ?Ñ+Ô+¨aÒ/Ð/°E°Mà ) 	Ð*LÐ*LÀeÐ*LÑ*LÔ*LÕTZÐ [Ñ [Ô [˜Ý”z %¨uÐ5Ñ5Ô5Ð5r*   r4   )r.   r   Ú
TENSORFLOWr   ÚImportErrorÚ
tensorflowÚconstantÚ	is_tensorÚPYTORCHr   rP   ÚJAXr   Ú	jax.numpyÚnumpyrM   r   r   )r'   r"   Útfrc   ÚjnprQ   rP   s        @@r)   Ú_get_is_as_tensor_fnsz"BatchFeature._get_is_as_tensor_fnss   sU  øø€ ØÐØ�:õ ˜+¥zÑ2Ô2ð 	2Ý$ [Ñ1Ô1ˆKð �*Ô/Ò/Ð/Ý"Ñ$Ô$ð Ý!Øiñô ð ð $Ð#Ð#Ð#àœˆIØœˆIˆIØ�JÔ.Ò.Ð.Ý%Ñ'Ô'ð sÝ!Ð"qÑrÔrÐrØˆLˆLˆLð+ð +ð +ð +ð +ð
 œˆIˆIØ�JœNÒ*Ð*Ý$Ñ&Ô&ð kÝ!Ð"iÑjÔjÐjØ#Ð#Ð#Ð#Ð#Ð#àœ	ˆIÝ%ˆIˆIð6ð 6ð 6ð 6ð 6ð 6õ 'ˆIØ˜)Ð#Ð#r*   c                 óü   — |€| S |                       |¦  «        \  }}|                      ¦   «         D ]J\  }}	  ||¦  «        s ||¦  «        }|| |<   Œ"#  |dk    rt          d¦  «        ‚t          d¦  «        ‚xY w| S )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.
        NÚ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.)rj   rD   Ú
ValueError)r'   r"   rc   rQ   ÚkeyrO   rN   s          r)   r&   zBatchFeature.convert_to_tensors¤   s·   € ð ÐØˆKà#×9Ò9¸+ÑFÔFÑˆ	�9ð Ÿ*š*™,œ,ð 	ð 	‰JˆC�ðØ �y Ñ'Ô'ð 'Ø&˜Y uÑ-Ô-�Fà &�D˜‘IøøðØÐ.Ò.Ð.Ý$Ð%rÑsÔsÐsÝ ðXñô ð øøøð
 ˆs   ·AÁ&A9c                 ó6  — t          | dg¦  «         ddl}i }|                     d¦  «        }|€‡t          |¦  «        dk    rt|d         }t	          |¦  «        rn\t          |t          ¦  «        s$t          |¦  «        st          |t          ¦  «        r|}n t          dt          |¦  «        › d�¦  «        ‚|  
                    ¦   «         D ]G\  }} |j        |¦  «        r |j        |i |¤Ž||<   Œ&|�|                     |¬¦  «        ||<   ŒB|||<   ŒH|| _        | S )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.

        Returns:
            [`BatchFeature`]: The same instance after modification.
        rP   r   NÚdevicez*Attempting to cast a BatchFeature to type z. This is not supported.)rp   )r   rP   ÚgetrJ   r   r.   r/   r   Úintrm   rD   Úis_floating_pointÚtor!   )	r'   ÚargsÚkwargsrP   Únew_datarp   ÚargÚkÚvs	            r)   rt   zBatchFeature.toÃ   sG  € õ 	˜$  	Ñ*Ô*Ð*ØˆˆˆàˆØ—’˜HÑ%Ô%ˆàˆ>�c $™iœi¨!šm˜mà�q”'ˆCÝ˜cÑ"Ô"ð ràÝ˜C¥Ñ%Ô%ð r­¸Ñ)=Ô)=ð rÅÈCÕQTÑAUÔAUð rØ��õ !Ð!pÍcÐRUÉhÌhÐ!pÐ!pÐ!pÑqÔqÐqà—J’J‘L”Lð 	 ð 	 ‰DˆAˆqà&ˆuÔ& qÑ)Ô)ð  à"˜aœd DÐ3¨FÐ3Ð3�˜‘�ØÐ#ØŸdšd¨&˜dÑ1Ô1�˜‘�à�˜‘�ØˆŒ	Øˆr*   rF   r4   )r,   r    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r/   r   r	   r   r%   r2   r6   r;   r>   r@   rB   rD   rj   r&   rt   Ú__classcell__)r(   s   @r)   r    r    =   sy  ø€ € € € € ðð ð9ð 9˜X d¨3°¨8¤nÔ5ð 9È5ÐQUÐWZÐ\fÐQfÔKgð 9ð 9ð 9ð 9ð 9ð 9ðq ð q¨¨c¬
ð qð qð qð qð! ð !ð !ð !ð !ð#ð #ð #ð&ð &ð &ð
 ð  ð  ð"ð "ð "ð!ð !ð !ð/$ð /$°¸%ÀÀZÀÔ:PÔ1Qð /$ð /$ð /$ð /$ðbð ¨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e
j        f         d	ee	ee
j        f                  d
ededee	eef                  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fd„¦   «         Zdeeef         fd„Zede	ee
j        f         defd„¦   «         Zdefd„Zde	ee
j        f         fd„Zd„ Zed!d„¦   «         ZdS )"ÚFeatureExtractionMixinzŠ
    This is a feature extraction mixin used to provide saving/loading functionality for sequential and image feature
    extractors.
    Nc           
      ó  — |                      dd¦  «        | _        |                     ¦   «         D ]N\  }}	 t          | ||¦  «         Œ# t          $ r*}t
                               d|› d|› d| › �¦  «         |‚d}~ww xY wdS )z'Set elements of `kwargs` as attributes.Úprocessor_classNz
Can't set z with value z for )ÚpopÚ_processor_classrD   Úsetattrr5   ÚloggerÚerror)r'   rv   rn   rO   Úerrs        r)   r%   zFeatureExtractionMixin.__init__ø   s©   € ð !'§
¢
Ð+<¸dÑ CÔ CˆÔà Ÿ,š,™.œ.ð 	ð 	‰JˆC�ðÝ˜˜c 5Ñ)Ô)Ð)Ð)øÝ!ð ð ð Ý—’ÐM¨#ÐMÐM¸5ÐMÐMÀtÐMÐMÑNÔNÐNØ�	øøøøðøøøð	ð 	s   ¶AÁ
A<Á%A7Á7A<rƒ   c                 ó   — || _         dS )z%Sets processor class as an attribute.N)r…   )r'   rƒ   s     r)   Ú_set_processor_classz+FeatureExtractionMixin._set_processor_class  s   € à /ˆÔÐÐr*   FÚmainÚpretrained_model_name_or_pathÚ	cache_dirÚforce_downloadÚlocal_files_onlyÚtokenÚrevisionc                 ó   — ||d<   ||d<   ||d<   ||d<   |                      dd¦  «        }|�-t          j        dt          ¦  «         |�t	          d¦  «        ‚|}|�||d	<    | j        |fi |¤Ž\  }	} | j        |	fi |¤ŽS )
az  
        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. Valid model ids can be located at the root-level, like `bert-base-uncased`, or
                  namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`.
                - 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 (`bool`, *optional*, defaults to `False`):
                Whether or not to delete incompletely received file. Attempts to resume the download if such a file
                exists.
            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 `huggingface-cli 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ÚFutureWarningrm   Úget_feature_extractor_dictÚ	from_dict)
Úclsr�   rŽ   r�   r�   r‘   r’   rv   r”   Úfeature_extractor_dicts
             r)   Úfrom_pretrainedz&FeatureExtractionMixin.from_pretrained  sÖ   € ðr (ˆˆ{ÑØ#1ˆÐÑ Ø%5ˆÐ!Ñ"Ø%ˆˆzÑàŸšÐ$4°dÑ;Ô;ˆØÐ%ÝŒMð EÝñô ð ð Ð Ý Ølñô ð ð #ˆEàÐØ#ˆF�7‰Oà)G¨Ô)GÐHeÐ)pÐ)pÐioÐ)pÐ)pÑ&Ð àˆsŒ}Ð3Ð>Ð>°vÐ>Ð>Ð>r*   Úsave_directoryÚpush_to_hubc           	      ó€  — |                      dd¦  «        }|�Dt          j        dt          ¦  «         |                     dd¦  «        �t          d¦  «        ‚||d<   t          j                             |¦  «        rt          d|› d�¦  «        ‚t          j
        |d¬	¦  «         |rw|                      d
d¦  «        }|                      d|                     t          j        j        ¦  «        d         ¦  «        } | j        |fi |¤Ž}|                      |¦  «        }| j        �t!          | || ¬¦  «         t          j                             |t$          ¦  «        }|                      |¦  «         t(                               d|› �¦  «         |r-|                      |||||                     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™   rq   rm   ÚosÚpathÚisfileÚAssertionErrorÚmakedirsÚsplitÚsepÚ_create_repoÚ_get_files_timestampsÚ_auto_classr   Újoinr   Úto_json_filer‡   ÚinfoÚ_upload_modified_files)	r'   rŸ   r    rv   r”   r£   r¤   Úfiles_timestampsÚoutput_feature_extractor_files	            r)   Úsave_pretrainedz&FeatureExtractionMixin.save_pretrainedy  sá  € ð  ŸšÐ$4°dÑ;Ô;ˆàÐ%ÝŒMð EÝñô ð ð �zŠz˜' 4Ñ(Ô(Ð4Ý Ølñô ð ð -ˆF�7‰OåŒ7�>Š>˜.Ñ)Ô)ð 	hÝ Ð!f°>Ð!fÐ!fÐ!fÑgÔgÐgå
Œ�N¨TÐ2Ñ2Ô2Ð2àð 	JØ#ŸZšZÐ(8¸$Ñ?Ô?ˆNØ—j’j ¨N×,@Ò,@ÅÄÄÑ,MÔ,MÈbÔ,QÑRÔRˆGØ'�dÔ'¨Ð:Ð:°6Ð:Ð:ˆGØ#×9Ò9¸.ÑIÔIÐð ÔÐ'Ý˜t ^¸DÐAÑAÔAÐAõ )+¬¯ª°^ÕE[Ñ(\Ô(\Ð%à×ÒÐ7Ñ8Ô8Ð8Ý�ŠÐQÐ2OÐQÐQÑRÔRÐRàð 	Ø×'Ò'ØØØ Ø-Ø—j’j Ñ)Ô)ð (ñ ô ð ð .Ð.Ð.r*   r,   c                 ó`  — |                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      d	d¦  «        }	|                      d
d¦  «        }
|�-t          j        dt          ¦  «         |�t	          d¦  «        ‚|}|                      dd¦  «        }|                      dd¦  «        }d|dœ}|�||d<   t          ¦   «         r|	st                               d¦  «         d}	t          |¦  «        }t          j
                             |¦  «        }t          j
                             |¦  «        r%t          j
                             |t          ¦  «        }t          j
                             |¦  «        r|}d}nyt          |¦  «        r|}t!          |¦  «        }nXt          }	 t#          |||||||	|||
¬¦
  «
        }n6# t$          $ r ‚ t&          $ r t%          d|› d|› dt          › d�¦  «        ‚w xY w	 t)          |dd¬¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   t-          j        |¦  «        }n&# t,          j        $ r t%          d|› d�¦  «        ‚w xY w|rt                               d|› �¦  «         n t                               d|› d|› �¦  «         d |v r|st3          |d          |¦  «        |d <   ||fS )!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Úproxiesr‘   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)rŽ   r�   rº   r¹   r�   r‘   Ú
user_agentr’   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Úrúutf-8©Úencodingz"It looks like the config file at 'z' is not a valid JSON file.zloading configuration file z from cache at Úauto_map)r„   r—   r˜   r™   rm   r   r‡   r³   r/   r§   r¨   Úisdirr±   r   r©   r   r   r   ÚEnvironmentErrorÚ	ExceptionÚopenÚreadÚjsonÚloadsÚJSONDecodeErrorr   )rœ   r�   rv   rŽ   r�   r¹   rº   r‘   r”   r�   r’   Úfrom_pipeliner¿   rÁ   Úis_localÚfeature_extractor_fileÚresolved_feature_extractor_fileÚreaderÚtextr�   s                       r)   rš   z1FeatureExtractionMixin.get_feature_extractor_dict¶  s   € ð —J’J˜{¨DÑ1Ô1ˆ	ØŸšÐ$4°eÑ<Ô<ˆØ Ÿ*š*Ð%6¸Ñ>Ô>ˆØ—*’*˜Y¨Ñ-Ô-ˆØ—
’
˜7 DÑ)Ô)ˆØŸšÐ$4°dÑ;Ô;ˆØ!Ÿ:š:Ð&8¸%Ñ@Ô@ÐØ—:’:˜j¨$Ñ/Ô/ˆàÐ%ÝŒMð EÝñô ð ð Ð Ý Ølñô ð ð #ˆEàŸ
š
Ð#3°TÑ:Ô:ˆØ Ÿ*š* \°5Ñ9Ô9ˆà#6È?Ð[Ð[ˆ
ØÐ$Ø+8ˆJÐ'Ñ(åÑÔð 	$Ð%5ð 	$Ý�KŠKÐEÑFÔFÐFØ#Ðå(+Ð,IÑ(JÔ(JÐ%Ý”7—=’=Ð!>Ñ?Ô?ˆÝŒ7�=Š=Ð6Ñ7Ô7ð 	iÝ%'¤W§\¢\Ð2OÕQgÑ%hÔ%hÐ"ÝŒ7�>Š>Ð7Ñ8Ô8ð !	Ø.KÐ+ØˆHˆHÝÐ8Ñ9Ô9ð 	Ø%BÐ"Ý.:Ð;XÑ.YÔ.YÐ+Ð+å%;Ð"ðå2=Ø1Ø*Ø'Ø#1Ø#Ø$3Ø%5ØØ)Ø%ð3ñ 3ô 3Ð/Ð/øõ $ð ð ð ð Ýð ð ð å&ðMÐ9Vð Mð Mà9VðMð Mõ 0FðMð Mð Mñô ð ðøøøð		åÐ5°sÀWÐMÑMÔMð %ÐQWØ—{’{‘}”}�ð%ð %ð %ñ %ô %ð %ð %ð %ð %ð %ð %øøøð %ð %ð %ð %å%)¤Z°Ñ%5Ô%5Ð"Ð"øåÔ#ð 	ð 	ð 	Ý"ØqÐ5TÐqÐqÐqñô ð ð	øøøð
 ð 	Ý�KŠKÐWÐ6UÐWÐWÑXÔXÐXÐXå�KŠKØvÐ.DÐvÐvÐUtÐvÐvñô ð ð Ð/Ð/Ð/¸Ð/Ý1KØ& zÔ2Ð4Qñ2ô 2Ð" :Ñ.ð & vÐ-Ð-s<   ÈH È3IÉJ' É&JÉ;J' ÊJÊJ' ÊJÊJ' Ê'#K
r�   c                 ób  — |                      dd¦  «        } | di |¤Ž}g }|                     ¦   «         D ];\  }}t          ||¦  «        r&t          |||¦  «         |                     |¦  «         Œ<|D ]}|                      |d¦  «         Œt
                               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 rT   )r„   rD   Úhasattrr†   Úappendr‡   r³   )rœ   r�   rv   rÖ   Úfeature_extractorÚ	to_removern   rO   s           r)   r›   z FeatureExtractionMixin.from_dict$  sè   € ð$  &ŸzšzÐ*@À%ÑHÔHÐà˜CÐ9Ð9Ð"8Ð9Ð9Ðð ˆ	Ø Ÿ,š,™.œ.ð 	&ð 	&‰JˆC�ÝÐ(¨#Ñ.Ô.ð &ÝÐ)¨3°Ñ6Ô6Ð6Ø× Ò  Ñ%Ô%Ð%øØð 	"ð 	"ˆCØ�JŠJ�s˜DÑ!Ô!Ð!Ð!å�ŠÐ<Ð):Ð<Ð<Ñ=Ô=Ð=Øð 	%Ø$ fÐ,Ð,à$Ð$r*   c                 óV   — t          j        | j        ¦  «        }| j        j        |d<   |S )zÁ
        Serializes this instance to a Python dictionary.

        Returns:
            `Dict[str, Any]`: Dictionary of all the attributes that make up this feature extractor instance.
        Úfeature_extractor_type)ÚcopyÚdeepcopyÚ__dict__r(   r{   )r'   Úoutputs     r)   Úto_dictzFeatureExtractionMixin.to_dictI  s*   € õ ”˜tœ}Ñ-Ô-ˆØ+/¬>Ô+BˆÐ'Ñ(àˆr*   Ú	json_filec                 ó¶   — t          |dd¬¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   t          j        |¦  «        } | di |¤ŽS )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Ã   rÄ   NrT   )rÊ   rË   rÌ   rÍ   )rœ   râ   rÓ   rÔ   r�   s        r)   Úfrom_json_filez%FeatureExtractionMixin.from_json_fileU  sŸ   € õ �)˜S¨7Ð3Ñ3Ô3ð 	!°vØ—;’;‘=”=ˆDð	!ð 	!ð 	!ñ 	!ô 	!ð 	!ð 	!ð 	!ð 	!ð 	!ð 	!øøøð 	!ð 	!ð 	!ð 	!å!%¤¨DÑ!1Ô!1ÐØˆsÐ,Ð,Ð+Ð,Ð,Ð,s   “4´8»8c                 ó.  — |                       ¦   «         }|                     ¦   «         D ]6\  }}t          |t          j        ¦  «        r|                     ¦   «         ||<   Œ7|                     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á   rD   r.   rK   rL   Útolistr„   rÌ   Údumps)r'   Ú
dictionaryrn   rO   r…   s        r)   Úto_json_stringz%FeatureExtractionMixin.to_json_stringh  sš   € ð —\’\‘^”^ˆ
à$×*Ò*Ñ,Ô,ð 	1ð 	1‰JˆC�Ý˜%¥¤Ñ,Ô,ð 1Ø"'§,¢,¡.¤.�
˜3‘øð &Ÿ>š>Ð*<¸dÑCÔCÐØÐ'Ø,<ˆJÐ(Ñ)åŒz˜*¨Q¸$Ð?Ñ?Ô?À$ÑFÐFr*   Újson_file_pathc                 óª   — t          |dd¬¦  «        5 }|                     |                      ¦   «         ¦  «         ddd¦  «         dS # 1 swxY w Y   dS )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Ñ8Ô8ð 	0¸FØ�LŠL˜×,Ò,Ñ.Ô.Ñ/Ô/Ð/ð	0ð 	0ð 	0ñ 	0ô 	0ð 	0ð 	0ð 	0ð 	0ð 	0ð 	0ð 	0øøøð 	0ð 	0ð 	0ð 	0ð 	0ð 	0s   “(AÁAÁAc                 óH   — | j         j        › d|                      ¦   «         › �S )Nú )r(   r{   rí   r:   s    r)   Ú__repr__zFeatureExtractionMixin.__repr__ˆ  s'   € Ø”.Ô)ÐCÐC¨D×,?Ò,?Ñ,AÔ,AÐCÐCÐCr*   ÚAutoFeatureExtractorc                 ó¢   — t          |t          ¦  «        s|j        }ddlmc m} t          ||¦  «        st          |› d�¦  «        ‚|| _        dS )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`.

        <Tip warning={true}>

        This API is experimental and may have some slight breaking changes in the next releases.

        </Tip>

        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.)	r.   r/   r{   Útransformers.models.autoÚmodelsÚautor×   rm   r°   )rœ   Ú
auto_classÚauto_modules      r)   Úregister_for_auto_classz.FeatureExtractionMixin.register_for_auto_class‹  sn   € õ  ˜*¥cÑ*Ô*ð 	-Ø#Ô,ˆJà6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6å�{ JÑ/Ô/ð 	IÝ 
ÐGÐGÐGÑHÔHÐHà$ˆŒˆˆr*   )NFFNrŒ   )F)rö   )r{   r|   r}   r~   r°   r%   r/   r‹   Úclassmethodr	   r§   ÚPathLiker   Úboolrž   r·   r   r   r   rš   ÚPreTrainedFeatureExtractorr›   rá   rä   rí   r²   rõ   rý   rT   r*   r)   r�   r�   ð   s—  € € € € € ðð ð
 €Kð
ð 
ð 
ð0°Cð 0ð 0ð 0ð 0ð ð 8<Ø$Ø!&Ø,0Øðn?ð n?à',¨S°"´+Ð-=Ô'>ðn?ð ˜E # r¤{Ð"2Ô3Ô4ðn?ð ð	n?ð
 ðn?ð ˜˜c 4˜iÔ(Ô)ðn?ð ðn?ð n?ð n?ñ „[ðn?ð`;/ð ;/¨e°C¸¼Ð4DÔ.Eð ;/ÐTXð ;/ð ;/ð ;/ð ;/ðz ðk.Ø,1°#°r´{Ð2BÔ,Cðk.à	ˆt�C˜�HŒ~˜t C¨ Hœ~Ð-Ô	.ðk.ð k.ð k.ñ „[ðk.ðZ ð"%¨t°C¸°H¬~ð "%ÐLfð "%ð "%ð "%ñ „[ð"%ðH
˜˜c 3˜hœð 
ð 
ð 
ð 
ð ð- u¨S°"´+Ð-=Ô'>ð -ÐC]ð -ð -ð -ñ „[ð-ð$G ð Gð Gð Gð Gð*	0¨5°°b´kÐ1AÔ+Bð 	0ð 	0ð 	0ð 	0ðDð Dð Dð ð%ð %ð %ñ „[ð%ð %ð %r*   r�   r½   rö   zfeature extractor file)r]   Úobject_classÚobject_files).r~   rÝ   rÌ   r§   r—   Úcollectionsr   Útypingr   r   r   r   r   r	   rg   rK   Údynamic_module_utilsr   Úutilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rP   Ú
get_loggerr{   r‡   r  r    r�   r    ÚformatrT   r*   r)   ú<module>r
     sk  ððð ð €€€Ø €€€Ø 	€	€	€	Ø €€€Ø  Ð  Ð  Ð  Ð  Ð  Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cà Ð Ð Ð à 4Ð 4Ð 4Ð 4Ð 4Ð 4ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð, ð ØÐÑÔð Øˆˆˆð 
ˆÔ	˜HÑ	%Ô	%€à"Ð#=Ô>Ð ðpð pð pð pð p�8ñ pô pð pðfs%ð s%ð s%ð s%ð s%˜^ñ s%ô s%ð s%ðl &/ YÐ/EÔ/QÑ%RÔ%RÐ Ô "ØÔ%Ô-Ð9Ø1GÔ1SÔ1[×1bÒ1bØ"Ð1GÐVnð 2cñ 2ô 2ÐÔ&Ô.Ð.Ð.ð :Ð9r*   