U
    4Afo                  E   @   s  d Z ddlZddlmZ ddlmZ ddlmZmZm	Z	 ddl
mZ eeZed	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLgDZedMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfgZedgdNdhdPdidQdRdjdkdTdldVdWdmdYdndodpdqd\d]drd^d_dsdtd`dadbdudddedfg!ZedvdwdQdVdWdmdxd]dydzd{d|d}dbd~ddddfgZeddgZedddddddddddddgZeddgZedddgZeddgZedgdhdPdidddRdjdkdTdldYdodqd\drd^d_dsdadddegZedNddddndpdddd`g
ZedtdugZeddddddddddddddddddddddddddddddddg ZeddddddddddddddddddddddgZedgZeddgZedgZedddddddddddddddddddddddgZ edddddddddddddddddddgZ!edd gZ"ed<gZ#ed	dddddddd*d/dd7d9d:d;ddJdKgZ$eeeZ%eeeZ&eeeZ'eeeZ(eeeZ)eeeZ*eeeZ+eeeZ,eeeZ-eeeZ.eeeZ/eeeZ0eeeZ1eeeZ2eeeZ3eeeZ4eee Z5eee!Z6eee"Z7eeeZ8eee#Z9eee$Z:G dd deZ;G dd deZ<G dd deZ=e	e=Z=G d	d
 d
eZ>e	e>ddZ>G dd deZ?e	e?ddZ?G dd deZ@e	e@ddZ@G dd deZAe	eAddZAG dd deZBe	eBddZBG dd deZCe	eCddZCG dd deZDe	eDddZDG dd  d eZEe	eEd!dZEG d"d# d#eZFe	eFd$dZFG d%d& d&eZGe	eGd'dZGG d(d) d)eZHe	eHd*d+d,ZHG d-d. d.eZIe	eId/dZIG d0d1 d1eZJe	eJd2dZJG d3d4 d4eZKe	eKd5d6d,ZKG d7d8 d8eZLe	eLd9d:d,ZLG d;d< d<eZMe	eMd=dZMG d>d? d?eZNe	eNd@dZNG dAdB dBeZOe	eOdCdZOG dDdE dEeZPe	ePdFdZPG dGdH dHe@ZQdS (I  zAuto Model class.    N)OrderedDict   )logging   )_BaseAutoModelClass_LazyAutoMappingauto_class_update)CONFIG_MAPPING_NAMES)albertZTFAlbertModel)bartZTFBartModel)bertZTFBertModel)
blenderbotZTFBlenderbotModel)blenderbot-smallZTFBlenderbotSmallModel)blipZTFBlipModel)	camembertZTFCamembertModel)ZclipZTFCLIPModel)convbertZTFConvBertModel)convnextZTFConvNextModel)
convnextv2ZTFConvNextV2Model)ctrlZTFCTRLModel)cvtZ
TFCvtModel)data2vec-visionZTFData2VecVisionModel)debertaZTFDebertaModel)
deberta-v2ZTFDebertaV2Model)deitZTFDeiTModel)
distilbertZTFDistilBertModel)ZdprZTFDPRQuestionEncoder)efficientformerZTFEfficientFormerModel)electraZTFElectraModel)esmZ
TFEsmModel)flaubertZTFFlaubertModel)funnel)ZTFFunnelModelZTFFunnelBaseModel)gpt-sw3TFGPT2Model)gpt2r!   )gptjZTFGPTJModel)ZgroupvitZTFGroupViTModel)ZhubertZTFHubertModel)ideficsZTFIdeficsModel)layoutlmZTFLayoutLMModel)
layoutlmv3ZTFLayoutLMv3Model)ledZ
TFLEDModel)
longformerZTFLongformerModel)lxmertZTFLxmertModel)marianZTFMarianModel)mbartZTFMBartModel)mistralZTFMistralModel)
mobilebertZTFMobileBertModel)	mobilevitZTFMobileViTModel)mpnetZTFMPNetModel)mt5Z
TFMT5Model)
openai-gptZTFOpenAIGPTModel)optZ
TFOPTModel)pegasusZTFPegasusModel)regnetZTFRegNetModel)rembertZTFRemBertModel)resnetZTFResNetModel)robertaZTFRobertaModel)roberta-prelayernormZTFRobertaPreLayerNormModel)roformerZTFRoFormerModel)ZsamZ
TFSamModel)	segformerZTFSegformerModel)speech_to_textZTFSpeech2TextModel)swiftformerZTFSwiftFormerModel)swinZTFSwinModel)t5Z	TFT5Model)tapasZTFTapasModel)
transfo-xlZTFTransfoXLModel)zvision-text-dual-encoderZTFVisionTextDualEncoderModel)vitZ
TFViTModel)vit_maeZTFViTMAEModel)wav2vec2ZTFWav2Vec2Model)whisperZTFWhisperModel)xglmZTFXGLMModel)xlmZ
TFXLMModel)xlm-robertaZTFXLMRobertaModel)xlnetZTFXLNetModel)r
   ZTFAlbertForPreTraining)r   ZTFBartForConditionalGeneration)r   ZTFBertForPreTraining)r   ZTFCamembertForMaskedLM)r   ZTFCTRLLMHeadModel)r   ZTFDistilBertForMaskedLM)r   ZTFElectraForPreTraining)r   ZTFFlaubertWithLMHeadModel)r   ZTFFunnelForPreTraining)r    TFGPT2LMHeadModel)r"   rI   )r$   ZTFIdeficsForVisionText2Text)r%   ZTFLayoutLMForMaskedLM)r)   ZTFLxmertForPreTraining)r-   ZTFMobileBertForPreTraining)r/   ZTFMPNetForMaskedLM)r1   ZTFOpenAIGPTLMHeadModel)r7   ZTFRobertaForMaskedLM)r8   Z TFRobertaPreLayerNormForMaskedLM)r>   ZTFT5ForConditionalGeneration)r?   ZTFTapasForMaskedLM)r@   ZTFTransfoXLLMHeadModel)rB   ZTFViTMAEForPreTraining)rF   ZTFXLMWithLMHeadModel)rG   ZTFXLMRobertaForMaskedLM)rH   ZTFXLNetLMHeadModel)r
   ZTFAlbertForMaskedLM)r   ZTFBertForMaskedLM)r   ZTFConvBertForMaskedLM)r   ZTFElectraForMaskedLM)r   ZTFEsmForMaskedLM)r   ZTFFunnelForMaskedLM)r#   ZTFGPTJForCausalLM)r'   ZTFLEDForConditionalGeneration)r(   ZTFLongformerForMaskedLM)r*   ZTFMarianMTModel)r-   ZTFMobileBertForMaskedLM)r5   ZTFRemBertForMaskedLM)r9   ZTFRoFormerForMaskedLM)r;   Z%TFSpeech2TextForConditionalGeneration)rD   Z!TFWhisperForConditionalGeneration)r   ZTFBertLMHeadModel)r   ZTFCamembertForCausalLM)r,   ZTFMistralForCausalLM)r2   ZTFOPTForCausalLM)r5   ZTFRemBertForCausalLM)r7   ZTFRobertaForCausalLM)r8   Z TFRobertaPreLayerNormForCausalLM)r9   ZTFRoFormerForCausalLM)rE   ZTFXGLMForCausalLM)rG   ZTFXLMRobertaForCausalLM)r   ZTFDeiTForMaskedImageModeling)r=   ZTFSwinForMaskedImageModeling)r   Z TFConvNextForImageClassification)r   Z"TFConvNextV2ForImageClassification)r   ZTFCvtForImageClassification)r   Z&TFData2VecVisionForImageClassification)r   )ZTFDeiTForImageClassificationZ'TFDeiTForImageClassificationWithTeacher)r   )Z'TFEfficientFormerForImageClassificationZ2TFEfficientFormerForImageClassificationWithTeacher)r.   Z!TFMobileViTForImageClassification)r4   ZTFRegNetForImageClassification)r6   ZTFResNetForImageClassification)r:   Z!TFSegformerForImageClassification)r<   Z#TFSwiftFormerForImageClassification)r=   ZTFSwinForImageClassification)rA   ZTFViTForImageClassification)r   Z'TFData2VecVisionForSemanticSegmentation)r.   Z"TFMobileViTForSemanticSegmentation)r:   Z"TFSegformerForSemanticSegmentation)r   ZTFBlipForConditionalGeneration)zvision-encoder-decoderZTFVisionEncoderDecoderModel)r   ZTFDebertaForMaskedLM)r   ZTFDebertaV2ForMaskedLM)r   Z$TFBlenderbotForConditionalGeneration)r   Z)TFBlenderbotSmallForConditionalGeneration)zencoder-decoderZTFEncoderDecoderModel)r+   ZTFMBartForConditionalGeneration)r0   ZTFMT5ForConditionalGeneration)r3   Z!TFPegasusForConditionalGeneration)r
   Z!TFAlbertForSequenceClassification)r   ZTFBartForSequenceClassification)r   ZTFBertForSequenceClassification)r   Z$TFCamembertForSequenceClassification)r   Z#TFConvBertForSequenceClassification)r   ZTFCTRLForSequenceClassification)r   Z"TFDebertaForSequenceClassification)r   Z$TFDebertaV2ForSequenceClassification)r   Z%TFDistilBertForSequenceClassification)r   Z"TFElectraForSequenceClassification)r   ZTFEsmForSequenceClassification)r   Z#TFFlaubertForSequenceClassification)r   Z!TFFunnelForSequenceClassification)r    TFGPT2ForSequenceClassification)r"   rJ   )r#   ZTFGPTJForSequenceClassification)r%   Z#TFLayoutLMForSequenceClassification)r&   Z%TFLayoutLMv3ForSequenceClassification)r(   Z%TFLongformerForSequenceClassification)r,   Z"TFMistralForSequenceClassification)r-   Z%TFMobileBertForSequenceClassification)r/   Z TFMPNetForSequenceClassification)r1   Z$TFOpenAIGPTForSequenceClassification)r5   Z"TFRemBertForSequenceClassification)r7   Z"TFRobertaForSequenceClassification)r8   Z.TFRobertaPreLayerNormForSequenceClassification)r9   Z#TFRoFormerForSequenceClassification)r?   Z TFTapasForSequenceClassification)r@   Z$TFTransfoXLForSequenceClassification)rF   ZTFXLMForSequenceClassification)rG   Z%TFXLMRobertaForSequenceClassification)rH   Z TFXLNetForSequenceClassification)r
   ZTFAlbertForQuestionAnswering)r   ZTFBertForQuestionAnswering)r   ZTFCamembertForQuestionAnswering)r   ZTFConvBertForQuestionAnswering)r   ZTFDebertaForQuestionAnswering)r   ZTFDebertaV2ForQuestionAnswering)r   Z TFDistilBertForQuestionAnswering)r   ZTFElectraForQuestionAnswering)r   Z$TFFlaubertForQuestionAnsweringSimple)r   ZTFFunnelForQuestionAnswering)r#   ZTFGPTJForQuestionAnswering)r&   Z TFLayoutLMv3ForQuestionAnswering)r(   Z TFLongformerForQuestionAnswering)r-   Z TFMobileBertForQuestionAnswering)r/   ZTFMPNetForQuestionAnswering)r5   ZTFRemBertForQuestionAnswering)r7   ZTFRobertaForQuestionAnswering)r8   Z)TFRobertaPreLayerNormForQuestionAnswering)r9   ZTFRoFormerForQuestionAnswering)rF   ZTFXLMForQuestionAnsweringSimple)rG   Z TFXLMRobertaForQuestionAnswering)rH   Z!TFXLNetForQuestionAnsweringSimple)rC   Z#TFWav2Vec2ForSequenceClassification)r%   ZTFLayoutLMForQuestionAnswering)r?   ZTFTapasForQuestionAnswering)r
   ZTFAlbertForTokenClassification)r   ZTFBertForTokenClassification)r   Z!TFCamembertForTokenClassification)r   Z TFConvBertForTokenClassification)r   ZTFDebertaForTokenClassification)r   Z!TFDebertaV2ForTokenClassification)r   Z"TFDistilBertForTokenClassification)r   ZTFElectraForTokenClassification)r   ZTFEsmForTokenClassification)r   Z TFFlaubertForTokenClassification)r   ZTFFunnelForTokenClassification)r%   Z TFLayoutLMForTokenClassification)r&   Z"TFLayoutLMv3ForTokenClassification)r(   Z"TFLongformerForTokenClassification)r-   Z"TFMobileBertForTokenClassification)r/   ZTFMPNetForTokenClassification)r5   ZTFRemBertForTokenClassification)r7   ZTFRobertaForTokenClassification)r8   Z+TFRobertaPreLayerNormForTokenClassification)r9   Z TFRoFormerForTokenClassification)rF   ZTFXLMForTokenClassification)rG   Z"TFXLMRobertaForTokenClassification)rH   ZTFXLNetForTokenClassification)r
   ZTFAlbertForMultipleChoice)r   ZTFBertForMultipleChoice)r   ZTFCamembertForMultipleChoice)r   ZTFConvBertForMultipleChoice)r   ZTFDebertaV2ForMultipleChoice)r   ZTFDistilBertForMultipleChoice)r   ZTFElectraForMultipleChoice)r   ZTFFlaubertForMultipleChoice)r   ZTFFunnelForMultipleChoice)r(   ZTFLongformerForMultipleChoice)r-   ZTFMobileBertForMultipleChoice)r/   ZTFMPNetForMultipleChoice)r5   ZTFRemBertForMultipleChoice)r7   ZTFRobertaForMultipleChoice)r8   Z&TFRobertaPreLayerNormForMultipleChoice)r9   ZTFRoFormerForMultipleChoice)rF   ZTFXLMForMultipleChoice)rG   ZTFXLMRobertaForMultipleChoice)rH   ZTFXLNetForMultipleChoice)r   ZTFBertForNextSentencePrediction)r-   Z%TFMobileBertForNextSentencePrediction)r0   ZTFMT5EncoderModel)r>   ZTFT5EncoderModelc                   @   s   e Zd ZeZdS )TFAutoModelForMaskGenerationN)__name__
__module____qualname__$TF_MODEL_FOR_MASK_GENERATION_MAPPING_model_mapping rQ   rQ   M/tmp/pip-unpacked-wheel-zw5xktn0/transformers/models/auto/modeling_tf_auto.pyrK     s   rK   c                   @   s   e Zd ZeZdS )TFAutoModelForTextEncodingN)rL   rM   rN   "TF_MODEL_FOR_TEXT_ENCODING_MAPPINGrP   rQ   rQ   rQ   rR   rS     s   rS   c                   @   s   e Zd ZeZdS )TFAutoModelN)rL   rM   rN   TF_MODEL_MAPPINGrP   rQ   rQ   rQ   rR   rU     s   rU   c                   @   s   e Zd ZeZdS )!TFAutoModelForAudioClassificationN)rL   rM   rN   )TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPINGrP   rQ   rQ   rQ   rR   rW      s   rW   zaudio classification)head_docc                   @   s   e Zd ZeZdS )TFAutoModelForPreTrainingN)rL   rM   rN    TF_MODEL_FOR_PRETRAINING_MAPPINGrP   rQ   rQ   rQ   rR   rZ   )  s   rZ   Zpretrainingc                   @   s   e Zd ZeZdS )_TFAutoModelWithLMHeadN)rL   rM   rN   TF_MODEL_WITH_LM_HEAD_MAPPINGrP   rQ   rQ   rQ   rR   r\   1  s   r\   zlanguage modelingc                   @   s   e Zd ZeZdS )TFAutoModelForCausalLMN)rL   rM   rN   TF_MODEL_FOR_CAUSAL_LM_MAPPINGrP   rQ   rQ   rQ   rR   r^   8  s   r^   zcausal language modelingc                   @   s   e Zd ZeZdS )!TFAutoModelForMaskedImageModelingN)rL   rM   rN   *TF_MODEL_FOR_MASKED_IMAGE_MODELING_MAPPINGrP   rQ   rQ   rQ   rR   r`   ?  s   r`   zmasked image modelingc                   @   s   e Zd ZeZdS )!TFAutoModelForImageClassificationN)rL   rM   rN   )TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPINGrP   rQ   rQ   rQ   rR   rb   H  s   rb   zimage classificationc                   @   s   e Zd ZeZdS ))TFAutoModelForZeroShotImageClassificationN)rL   rM   rN   3TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPINGrP   rQ   rQ   rQ   rR   rd   Q  s   rd   zzero-shot image classificationc                   @   s   e Zd ZeZdS )"TFAutoModelForSemanticSegmentationN)rL   rM   rN   *TF_MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPINGrP   rQ   rQ   rQ   rR   rf   Z  s   rf   zsemantic segmentationc                   @   s   e Zd ZeZdS )TFAutoModelForVision2SeqN)rL   rM   rN   !TF_MODEL_FOR_VISION_2_SEQ_MAPPINGrP   rQ   rQ   rQ   rR   rh   c  s   rh   zvision-to-text modelingc                   @   s   e Zd ZeZdS )TFAutoModelForMaskedLMN)rL   rM   rN   TF_MODEL_FOR_MASKED_LM_MAPPINGrP   rQ   rQ   rQ   rR   rj   j  s   rj   zmasked language modelingc                   @   s   e Zd ZeZdS )TFAutoModelForSeq2SeqLMN)rL   rM   rN   )TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPINGrP   rQ   rQ   rQ   rR   rl   q  s   rl   z&sequence-to-sequence language modelingzgoogle-t5/t5-base)rY   Zcheckpoint_for_examplec                   @   s   e Zd ZeZdS )$TFAutoModelForSequenceClassificationN)rL   rM   rN   ,TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPINGrP   rQ   rQ   rQ   rR   rn   |  s   rn   zsequence classificationc                   @   s   e Zd ZeZdS )TFAutoModelForQuestionAnsweringN)rL   rM   rN   'TF_MODEL_FOR_QUESTION_ANSWERING_MAPPINGrP   rQ   rQ   rQ   rR   rp     s   rp   zquestion answeringc                   @   s   e Zd ZeZdS )'TFAutoModelForDocumentQuestionAnsweringN)rL   rM   rN   0TF_MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPINGrP   rQ   rQ   rQ   rR   rr     s   rr   zdocument question answeringz/impira/layoutlm-document-qa", revision="52e01b3c                   @   s   e Zd ZeZdS )$TFAutoModelForTableQuestionAnsweringN)rL   rM   rN   -TF_MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPINGrP   rQ   rQ   rQ   rR   rt     s   rt   ztable question answeringzgoogle/tapas-base-finetuned-wtqc                   @   s   e Zd ZeZdS )!TFAutoModelForTokenClassificationN)rL   rM   rN   )TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPINGrP   rQ   rQ   rQ   rR   rv     s   rv   ztoken classificationc                   @   s   e Zd ZeZdS )TFAutoModelForMultipleChoiceN)rL   rM   rN   $TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPINGrP   rQ   rQ   rQ   rR   rx     s   rx   zmultiple choicec                   @   s   e Zd ZeZdS )$TFAutoModelForNextSentencePredictionN)rL   rM   rN   -TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPINGrP   rQ   rQ   rQ   rR   rz     s   rz   znext sentence predictionc                   @   s   e Zd ZeZdS )TFAutoModelForSpeechSeq2SeqN)rL   rM   rN   %TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPINGrP   rQ   rQ   rQ   rR   r|     s   r|   z,sequence-to-sequence speech-to-text modelingc                       s0   e Zd Ze fddZe fddZ  ZS )TFAutoModelWithLMHeadc                    s   t dt t |S Na  The class `TFAutoModelWithLMHead` is deprecated and will be removed in a future version. Please use `TFAutoModelForCausalLM` for causal language models, `TFAutoModelForMaskedLM` for masked language models and `TFAutoModelForSeq2SeqLM` for encoder-decoder models.)warningswarnFutureWarningsuperfrom_config)clsconfig	__class__rQ   rR   r     s
    z!TFAutoModelWithLMHead.from_configc                    s    t dt t j|f||S r   )r   r   r   r   from_pretrained)r   Zpretrained_model_name_or_pathZ
model_argskwargsr   rQ   rR   r     s
    z%TFAutoModelWithLMHead.from_pretrained)rL   rM   rN   classmethodr   r   __classcell__rQ   rQ   r   rR   r~     s   	r~   )R__doc__r   collectionsr   utilsr   Zauto_factoryr   r   r   Zconfiguration_autor	   Z
get_loggerrL   loggerZTF_MODEL_MAPPING_NAMESZ&TF_MODEL_FOR_PRETRAINING_MAPPING_NAMESZ#TF_MODEL_WITH_LM_HEAD_MAPPING_NAMESZ$TF_MODEL_FOR_CAUSAL_LM_MAPPING_NAMESZ0TF_MODEL_FOR_MASKED_IMAGE_MODELING_MAPPING_NAMESZ/TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMESZ9TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING_NAMESZ0TF_MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMESZ'TF_MODEL_FOR_VISION_2_SEQ_MAPPING_NAMESZ$TF_MODEL_FOR_MASKED_LM_MAPPING_NAMESZ/TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMESZ+TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMESZ2TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMESZ-TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMESZ/TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMESZ6TF_MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMESZ3TF_MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING_NAMESZ/TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMESZ*TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING_NAMESZ3TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING_NAMESZ*TF_MODEL_FOR_MASK_GENERATION_MAPPING_NAMESZ(TF_MODEL_FOR_TEXT_ENCODING_MAPPING_NAMESrV   r[   r]   r_   ra   rc   re   rg   ri   rk   rm   ro   r}   rq   rs   ru   rw   ry   r{   rX   rO   rT   rK   rS   rU   rW   rZ   r\   r^   r`   rb   rd   rf   rh   rj   rl   rn   rp   rr   rt   rv   rx   rz   r|   r~   rQ   rQ   rQ   rR   <module>   s8  
J '		&




    

           
         