o
    Zhiv                     @   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g d	Zeg d
Zeg dZeg dZeddgZeg dZeddgZeg dZeddgZeg dZeg dZeddgZeg dZeg dZedgZeddgZedgZeg dZ eg d Z!ed!d"gZ"ed#gZ#eg d$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/d0 d0eZ?e	e?d1d.Z?G d2d3 d3eZ@e	e@d4d.Z@G d5d6 d6eZAe	eAd7d.ZAG d8d9 d9eZBe	eBd:d.ZBG d;d< d<eZCe	eCd=d.ZCG d>d? d?eZDe	eDd@d.ZDG dAdB dBeZEe	eEdCd.ZEG dDdE dEeZFe	eFdFd.ZFG dGdH dHeZGe	eGdId.ZGG dJdK dKeZHe	eHdLdMdNZHG dOdP dPeZIe	eIdQd.ZIG dRdS dSeZJe	eJdTd.ZJG dUdV dVeZKe	eKdWdXdNZKG dYdZ dZeZLe	eLd[d\dNZLG d]d^ d^eZMe	eMd_d.ZMG d`da daeZNe	eNdbd.ZNG dcdd ddeZOe	eOded.ZOG dfdg dgeZPe	ePdhd.ZPG didj dje@ZQg dkZRdS )lzAuto Model class.    N)OrderedDict   )logging   )_BaseAutoModelClass_LazyAutoMappingauto_class_update)CONFIG_MAPPING_NAMES)E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)Zsam_vision_modelZTFSamVisionModel)	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,   rb   )r.   ZTFIdeficsForVisionText2Textr/   ZTFLayoutLMForMaskedLM)r4   ZTFLxmertForPreTraining)r9   ZTFMobileBertForPreTrainingr;   ZTFMPNetForMaskedLMr=   ZTFOpenAIGPTLMHeadModelrE   ZTFRobertaForMaskedLMrG   Z TFRobertaPreLayerNormForMaskedLMrO   ZTFT5ForConditionalGenerationrP   ZTFTapasForMaskedLMrQ   ZTFTransfoXLLMHeadModel)rS   ZTFViTMAEForPreTrainingrX   ZTFXLMWithLMHeadModelrZ   ZTFXLMRobertaForMaskedLMr[   ZTFXLNetLMHeadModel)!r   ZTFAlbertForMaskedLMr\   r   ZTFBertForMaskedLMr]   r   ZTFConvBertForMaskedLMr^   r_   r%   ZTFElectraForMaskedLMr&   ZTFEsmForMaskedLMr`   r)   ZTFFunnelForMaskedLMra   rc   r-   ZTFGPTJForCausalLMrd   r1   ZTFLEDForConditionalGenerationr3   ZTFLongformerForMaskedLMr5   ZTFMarianMTModelr9   ZTFMobileBertForMaskedLMre   rf   rB   ZTFRemBertForMaskedLMrg   rh   rI   ZTFRoFormerForMaskedLMrL   Z%TFSpeech2TextForConditionalGenerationri   rj   rk   rU   Z!TFWhisperForConditionalGenerationrl   rm   rn   ))r   ZTFBertLMHeadModel)r   ZTFCamembertForCausalLMr^   ra   rc   ru   )r7   ZTFMistralForCausalLMrf   )r>   ZTFOPTForCausalLM)rB   ZTFRemBertForCausalLM)rE   ZTFRobertaForCausalLM)rG   Z TFRobertaPreLayerNormForCausalLM)rI   ZTFRoFormerForCausalLMrk   )rV   ZTFXGLMForCausalLMrl   )rZ   ZTFXLMRobertaForCausalLMrn   )r    ZTFDeiTForMaskedImageModeling)rN   ZTFSwinForMaskedImageModeling))r   Z TFConvNextForImageClassification)r   Z"TFConvNextV2ForImageClassification)r   ZTFCvtForImageClassification)r   Z&TFData2VecVisionForImageClassification)r    )ZTFDeiTForImageClassificationZ'TFDeiTForImageClassificationWithTeacher)r#   )Z'TFEfficientFormerForImageClassificationZ2TFEfficientFormerForImageClassificationWithTeacher)r:   Z!TFMobileViTForImageClassification)r@   ZTFRegNetForImageClassification)rC   ZTFResNetForImageClassification)rK   Z!TFSegformerForImageClassification)rM   Z#TFSwiftFormerForImageClassification)rN   ZTFSwinForImageClassification)rR   ZTFViTForImageClassificationr   r   ))r   Z'TFData2VecVisionForSemanticSegmentation)r:   Z"TFMobileViTForSemanticSegmentation)rK   Z"TFSegformerForSemanticSegmentation)r   ZTFBlipForConditionalGeneration)zvision-encoder-decoderZTFVisionEncoderDecoderModel)ro   rp   r]   rq   )r   ZTFDebertaForMaskedLM)r   ZTFDebertaV2ForMaskedLMr_   rr   rs   r`   rt   rd   rw   ry   re   rz   rg   rh   r{   rj   rl   rm   )
r\   )r   Z$TFBlenderbotForConditionalGeneration)r   Z)TFBlenderbotSmallForConditionalGeneration)zencoder-decoderZTFEncoderDecoderModelrv   rx   )r6   ZTFMBartForConditionalGeneration)r<   ZTFMT5ForConditionalGeneration)r?   Z!TFPegasusForConditionalGenerationri   r|   r}   ) )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,   r~   )r-   ZTFGPTJForSequenceClassification)r/   Z#TFLayoutLMForSequenceClassification)r0   Z%TFLayoutLMv3ForSequenceClassification)r3   Z%TFLongformerForSequenceClassification)r7   Z"TFMistralForSequenceClassification)r9   Z%TFMobileBertForSequenceClassification)r;   Z TFMPNetForSequenceClassification)r=   Z$TFOpenAIGPTForSequenceClassification)rB   Z"TFRemBertForSequenceClassification)rE   Z"TFRobertaForSequenceClassification)rG   Z.TFRobertaPreLayerNormForSequenceClassification)rI   Z#TFRoFormerForSequenceClassification)rP   Z TFTapasForSequenceClassification)rQ   Z$TFTransfoXLForSequenceClassification)rX   ZTFXLMForSequenceClassification)rZ   Z%TFXLMRobertaForSequenceClassification)r[   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r0   Z TFLayoutLMv3ForQuestionAnswering)r3   Z TFLongformerForQuestionAnswering)r9   Z TFMobileBertForQuestionAnswering)r;   ZTFMPNetForQuestionAnswering)rB   ZTFRemBertForQuestionAnswering)rE   ZTFRobertaForQuestionAnswering)rG   Z)TFRobertaPreLayerNormForQuestionAnswering)rI   ZTFRoFormerForQuestionAnswering)rX   ZTFXLMForQuestionAnsweringSimple)rZ   Z TFXLMRobertaForQuestionAnswering)r[   Z!TFXLNetForQuestionAnsweringSimple)rT   Z#TFWav2Vec2ForSequenceClassification)r/   ZTFLayoutLMForQuestionAnsweringr   )rP   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)r0   Z"TFLayoutLMv3ForTokenClassification)r3   Z"TFLongformerForTokenClassification)r9   Z"TFMobileBertForTokenClassification)r;   ZTFMPNetForTokenClassification)rB   ZTFRemBertForTokenClassification)rE   ZTFRobertaForTokenClassification)rG   Z+TFRobertaPreLayerNormForTokenClassification)rI   Z TFRoFormerForTokenClassification)rX   ZTFXLMForTokenClassification)rZ   Z"TFXLMRobertaForTokenClassification)r[   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)r3   ZTFLongformerForMultipleChoice)r9   ZTFMobileBertForMultipleChoice)r;   ZTFMPNetForMultipleChoice)rB   ZTFRemBertForMultipleChoice)rE   ZTFRobertaForMultipleChoice)rG   Z&TFRobertaPreLayerNormForMultipleChoice)rI   ZTFRoFormerForMultipleChoice)rX   ZTFXLMForMultipleChoice)rZ   ZTFXLMRobertaForMultipleChoice)r[   ZTFXLNetForMultipleChoice)r   ZTFBertForNextSentencePrediction)r9   Z%TFMobileBertForNextSentencePredictionrJ   )r
   r   r   r   r   r!   r$   r'   r2   r8   )r<   ZTFMT5EncoderModelrA   rD   rF   rH   )rO   ZTFT5EncoderModelrW   rY   c                   @      e Zd ZeZdS )TFAutoModelForMaskGenerationN)__name__
__module____qualname__$TF_MODEL_FOR_MASK_GENERATION_MAPPING_model_mapping r   r   X/var/www/auris/lib/python3.10/site-packages/transformers/models/auto/modeling_tf_auto.pyr         r   c                   @   r   )TFAutoModelForTextEncodingN)r   r   r   "TF_MODEL_FOR_TEXT_ENCODING_MAPPINGr   r   r   r   r   r     r   r   c                   @   r   )TFAutoModelN)r   r   r   TF_MODEL_MAPPINGr   r   r   r   r   r     r   r   c                   @   r   )!TFAutoModelForAudioClassificationN)r   r   r   )TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPINGr   r   r   r   r   r   !  r   r   zaudio classification)head_docc                   @   r   )TFAutoModelForPreTrainingN)r   r   r    TF_MODEL_FOR_PRETRAINING_MAPPINGr   r   r   r   r   r   *  r   r   Zpretrainingc                   @   r   )_TFAutoModelWithLMHeadN)r   r   r   TF_MODEL_WITH_LM_HEAD_MAPPINGr   r   r   r   r   r   2  r   r   zlanguage modelingc                   @   r   )TFAutoModelForCausalLMN)r   r   r   TF_MODEL_FOR_CAUSAL_LM_MAPPINGr   r   r   r   r   r   9  r   r   zcausal language modelingc                   @   r   )!TFAutoModelForMaskedImageModelingN)r   r   r   *TF_MODEL_FOR_MASKED_IMAGE_MODELING_MAPPINGr   r   r   r   r   r   @  r   r   zmasked image modelingc                   @   r   )!TFAutoModelForImageClassificationN)r   r   r   )TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPINGr   r   r   r   r   r   I  r   r   zimage classificationc                   @   r   ))TFAutoModelForZeroShotImageClassificationN)r   r   r   3TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPINGr   r   r   r   r   r   R  r   r   zzero-shot image classificationc                   @   r   )"TFAutoModelForSemanticSegmentationN)r   r   r   *TF_MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPINGr   r   r   r   r   r   [  r   r   zsemantic segmentationc                   @   r   )TFAutoModelForVision2SeqN)r   r   r   !TF_MODEL_FOR_VISION_2_SEQ_MAPPINGr   r   r   r   r   r   d  r   r   zvision-to-text modelingc                   @   r   )TFAutoModelForMaskedLMN)r   r   r   TF_MODEL_FOR_MASKED_LM_MAPPINGr   r   r   r   r   r   k  r   r   zmasked language modelingc                   @   r   )TFAutoModelForSeq2SeqLMN)r   r   r   )TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPINGr   r   r   r   r   r   r  r   r   z&sequence-to-sequence language modelingzgoogle-t5/t5-base)r   Zcheckpoint_for_examplec                   @   r   )$TFAutoModelForSequenceClassificationN)r   r   r   ,TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPINGr   r   r   r   r   r   }  r   r   zsequence classificationc                   @   r   )TFAutoModelForQuestionAnsweringN)r   r   r   'TF_MODEL_FOR_QUESTION_ANSWERING_MAPPINGr   r   r   r   r   r     r   r   zquestion answeringc                   @   r   )'TFAutoModelForDocumentQuestionAnsweringN)r   r   r   0TF_MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPINGr   r   r   r   r   r     r   r   zdocument question answeringz/impira/layoutlm-document-qa", revision="52e01b3c                   @   r   )$TFAutoModelForTableQuestionAnsweringN)r   r   r   -TF_MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPINGr   r   r   r   r   r     r   r   ztable question answeringzgoogle/tapas-base-finetuned-wtqc                   @   r   )!TFAutoModelForTokenClassificationN)r   r   r   )TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPINGr   r   r   r   r   r     r   r   ztoken classificationc                   @   r   )TFAutoModelForMultipleChoiceN)r   r   r   $TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPINGr   r   r   r   r   r     r   r   zmultiple choicec                   @   r   )$TFAutoModelForNextSentencePredictionN)r   r   r   -TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPINGr   r   r   r   r   r     r   r   znext sentence predictionc                   @   r   )TFAutoModelForSpeechSeq2SeqN)r   r   r   %TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPINGr   r   r   r   r   r     r   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__r   r   r     s
   z!TFAutoModelWithLMHead.from_configc                    s&   t dt t j|g|R i |S r   )r   r   r   r   from_pretrained)r   Zpretrained_model_name_or_pathZ
model_argskwargsr   r   r   r     s
   z%TFAutoModelWithLMHead.from_pretrained)r   r   r   classmethodr   r   __classcell__r   r   r   r   r     s
    	r   ),r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )S__doc__r   collectionsr   utilsr   Zauto_factoryr   r   r   Zconfiguration_autor	   Z
get_loggerr   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_NAMESr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __all__r   r   r   r   <module>   s  
K '		&







