





import unittest

from parameterized import parameterized

from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          GPTNeoXForCausalLM,
          GPTNeoXForQuestionAnswering,
          GPTNeoXForSequenceClassification,
          GPTNeoXForTokenClassification,
          GPTNeoXModel,
      )

class 		UpperCamelCase__ :



     '''simple docstring'''

     def __init__(							self						:    int						,lowerCamelCase__						:    int						,lowerCamelCase__						:    Optional[int]=13						,lowerCamelCase__						:    Any=7						,lowerCamelCase__						:    List[str]=True						,lowerCamelCase__						:    Optional[int]=True						,lowerCamelCase__						:    Optional[Any]=True						,lowerCamelCase__						:    List[Any]=True						,lowerCamelCase__						:    str=99						,lowerCamelCase__						:    Dict=64						,lowerCamelCase__						:    Any=5						,lowerCamelCase__						:    Any=4						,lowerCamelCase__						:    List[Any]=37						,lowerCamelCase__						:    str="gelu"						,lowerCamelCase__						:    Any=0.1						,lowerCamelCase__						:    Optional[int]=0.1						,lowerCamelCase__						:    List[str]=512						,lowerCamelCase__						:    Union[str, Any]=16						,lowerCamelCase__						:    List[str]=2						,lowerCamelCase__						:    Optional[int]=0.02						,lowerCamelCase__						:    Any=3						,lowerCamelCase__						:    Dict=4						,lowerCamelCase__						:    List[str]=None						,)     ->		Dict:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						parent
           SCREAMING_SNAKE_CASE		=						batch_size
           SCREAMING_SNAKE_CASE		=						seq_length
           SCREAMING_SNAKE_CASE		=						is_training
           SCREAMING_SNAKE_CASE		=						use_input_mask
           SCREAMING_SNAKE_CASE		=						use_token_type_ids
           SCREAMING_SNAKE_CASE		=						use_labels
           SCREAMING_SNAKE_CASE		=						vocab_size
           SCREAMING_SNAKE_CASE		=						hidden_size
           SCREAMING_SNAKE_CASE		=						num_hidden_layers
           SCREAMING_SNAKE_CASE		=						num_attention_heads
           SCREAMING_SNAKE_CASE		=						intermediate_size
           SCREAMING_SNAKE_CASE		=						hidden_act
           SCREAMING_SNAKE_CASE		=						hidden_dropout_prob
           SCREAMING_SNAKE_CASE		=						attention_probs_dropout_prob
           SCREAMING_SNAKE_CASE		=						max_position_embeddings
           SCREAMING_SNAKE_CASE		=						type_vocab_size
           SCREAMING_SNAKE_CASE		=						type_sequence_label_size
           SCREAMING_SNAKE_CASE		=						initializer_range
           SCREAMING_SNAKE_CASE		=						num_labels
           SCREAMING_SNAKE_CASE		=						num_choices
           SCREAMING_SNAKE_CASE		=						scope
           SCREAMING_SNAKE_CASE		=						vocab_size - 1






     def 				SCREAMING_SNAKE_CASE__  (							self						:    List[str]       )     ->		Optional[int]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						ids_tensor([self.batch_size, self.seq_length]						,self.vocab_size       )

           SCREAMING_SNAKE_CASE		=						None
           if self.use_input_mask:
                 SCREAMING_SNAKE_CASE		=						random_attention_mask([self.batch_size, self.seq_length]       )

           SCREAMING_SNAKE_CASE		=						None
           if self.use_labels:
                 SCREAMING_SNAKE_CASE		=						ids_tensor([self.batch_size, self.seq_length]						,self.num_labels       )

           SCREAMING_SNAKE_CASE		=						self.get_config()

           return config, input_ids, input_mask, token_labels






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[Any]       )     ->		Dict:




           '''simple docstring'''


           return GPTNeoXConfig(
               vocab_size=self.vocab_size						,hidden_size=self.hidden_size						,num_hidden_layers=self.num_hidden_layers						,num_attention_heads=self.num_attention_heads						,intermediate_size=self.intermediate_size						,hidden_act=self.hidden_act						,hidden_dropout_prob=self.hidden_dropout_prob						,attention_probs_dropout_prob=self.attention_probs_dropout_prob						,max_position_embeddings=self.max_position_embeddings						,type_vocab_size=self.type_vocab_size						,is_decoder=lowerCamelCase__						,initializer_range=self.initializer_range						,pad_token_id=self.pad_token_id						,)






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Union[str, Any]       )     ->		Dict:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						self.prepare_config_and_inputs()

           SCREAMING_SNAKE_CASE		=						True

           return config, input_ids, input_mask, token_labels






     def 				SCREAMING_SNAKE_CASE__  (							self						:    str						,lowerCamelCase__						:    Union[str, Any]						,lowerCamelCase__						:    int						,lowerCamelCase__						:    Tuple       )     ->		Optional[int]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						GPTNeoXModel(config=lowerCamelCase__       )
           model.to(lowerCamelCase__       )
           model.eval()
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__						,attention_mask=lowerCamelCase__       )
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__       )
           self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, self.seq_length, self.hidden_size)       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Dict						,lowerCamelCase__						:    Any						,lowerCamelCase__						:    Tuple						,lowerCamelCase__						:    List[Any]       )     ->		str:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						True
           SCREAMING_SNAKE_CASE		=						GPTNeoXModel(lowerCamelCase__       )
           model.to(lowerCamelCase__       )
           model.eval()
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__						,attention_mask=lowerCamelCase__       )
           self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, self.seq_length, self.hidden_size)       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Dict						,lowerCamelCase__						:    int						,lowerCamelCase__						:    Optional[int]						,lowerCamelCase__						:    List[str]						,lowerCamelCase__						:    List[Any]       )     ->		str:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						GPTNeoXForCausalLM(config=lowerCamelCase__       )
           model.to(lowerCamelCase__       )
           model.eval()
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__						,attention_mask=lowerCamelCase__						,labels=lowerCamelCase__       )
           self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.seq_length, self.vocab_size)       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[int]						,lowerCamelCase__						:    List[str]						,lowerCamelCase__						:    Tuple						,lowerCamelCase__						:    str						,lowerCamelCase__						:    List[str]       )     ->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.num_labels
           SCREAMING_SNAKE_CASE		=						GPTNeoXForQuestionAnswering(lowerCamelCase__       )
           model.to(lowerCamelCase__       )
           model.eval()
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__						,attention_mask=lowerCamelCase__       )
           self.parent.assertEqual(result.start_logits.shape						,(self.batch_size, self.seq_length)       )
           self.parent.assertEqual(result.end_logits.shape						,(self.batch_size, self.seq_length)       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[Any]						,lowerCamelCase__						:    Optional[int]						,lowerCamelCase__						:    Optional[Any]						,lowerCamelCase__						:    Optional[Any]						,lowerCamelCase__						:    Dict       )     ->		str:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.num_labels
           SCREAMING_SNAKE_CASE		=						GPTNeoXForSequenceClassification(lowerCamelCase__       )
           model.to(lowerCamelCase__       )
           model.eval()
           SCREAMING_SNAKE_CASE		=						ids_tensor([self.batch_size]						,self.type_sequence_label_size       )
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__						,attention_mask=lowerCamelCase__						,labels=lowerCamelCase__       )
           self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.num_labels)       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[int]						,lowerCamelCase__						:    Any						,lowerCamelCase__						:    Any						,lowerCamelCase__						:    Dict						,lowerCamelCase__						:    List[str]       )     ->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.num_labels
           SCREAMING_SNAKE_CASE		=						GPTNeoXForTokenClassification(lowerCamelCase__       )
           model.to(lowerCamelCase__       )
           model.eval()
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__						,attention_mask=lowerCamelCase__						,labels=lowerCamelCase__       )
           self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.seq_length, self.num_labels)       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    List[str]						,lowerCamelCase__						:    str						,lowerCamelCase__						:    Union[str, Any]						,lowerCamelCase__						:    Tuple       )     ->		Dict:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						True
           SCREAMING_SNAKE_CASE		=						GPTNeoXForCausalLM(config=lowerCamelCase__       )
           model.to(lowerCamelCase__       )
           model.eval()

           # first forward pass
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__						,attention_mask=lowerCamelCase__						,use_cache=lowerCamelCase__       )
           SCREAMING_SNAKE_CASE		=						outputs.past_key_values

           # create hypothetical multiple next token and extent to next_input_ids
           SCREAMING_SNAKE_CASE		=						ids_tensor((self.batch_size, 3)						,config.vocab_size       )
           SCREAMING_SNAKE_CASE		=						ids_tensor((self.batch_size, 3)						,vocab_size=2       )

           # append to next input_ids and
           SCREAMING_SNAKE_CASE		=						torch.cat([input_ids, next_tokens]						,dim=-1       )
           SCREAMING_SNAKE_CASE		=						torch.cat([input_mask, next_mask]						,dim=-1       )

           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__						,attention_mask=lowerCamelCase__						,output_hidden_states=lowerCamelCase__       )
           SCREAMING_SNAKE_CASE		=						output_from_no_past["""hidden_states"""][0]
           SCREAMING_SNAKE_CASE		=						model(
               lowerCamelCase__						,attention_mask=lowerCamelCase__						,past_key_values=lowerCamelCase__						,output_hidden_states=lowerCamelCase__						,)["""hidden_states"""][0]

           # select random slice
           SCREAMING_SNAKE_CASE		=						ids_tensor((1,)						,output_from_past.shape[-1]       ).item()
           SCREAMING_SNAKE_CASE		=						output_from_no_past[:, -3:, random_slice_idx].detach()
           SCREAMING_SNAKE_CASE		=						output_from_past[:, :, random_slice_idx].detach()

           self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]       )

           # test that outputs are equal for slice
           self.parent.assertTrue(torch.allclose(lowerCamelCase__						,lowerCamelCase__						,atol=1e-3       )       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Dict       )     ->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.prepare_config_and_inputs()
           SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						config_and_inputs
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """attention_mask""": input_mask}
           return config, inputs_dict

@require_torch
class 		UpperCamelCase__ (      lowerCAmelCase_							,      lowerCAmelCase_							,      lowerCAmelCase_							,      unittest.TestCase   ):



     '''simple docstring'''

     __snake_case    :	Tuple			=			(
         (
             GPTNeoXModel,
             GPTNeoXForCausalLM,
             GPTNeoXForQuestionAnswering,
             GPTNeoXForSequenceClassification,
             GPTNeoXForTokenClassification,
         )
         if is_torch_available()
         else ()
     )
     __snake_case    :	Optional[int]			=			(GPTNeoXForCausalLM,) if is_torch_available() else ()
     __snake_case    :	Tuple			=			(
         {
             "feature-extraction": GPTNeoXModel,
             "question-answering": GPTNeoXForQuestionAnswering,
             "text-classification": GPTNeoXForSequenceClassification,
             "text-generation": GPTNeoXForCausalLM,
             "token-classification": GPTNeoXForTokenClassification,
             "zero-shot": GPTNeoXForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     __snake_case    :	List[str]			=			False
     __snake_case    :	Optional[int]			=			False
     __snake_case    :	Dict			=			False
     __snake_case    :	Union[str, Any]			=			False






     def 				SCREAMING_SNAKE_CASE__  (							self						:    str       )     ->		Tuple:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						GPTNeoXModelTester(self       )
           SCREAMING_SNAKE_CASE		=						ConfigTester(self						,config_class=lowerCamelCase__						,hidden_size=64						,num_attention_heads=8       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    List[str]       )     ->		str:




           '''simple docstring'''


           self.config_tester.run_common_tests()






     def 				SCREAMING_SNAKE_CASE__  (							self						:    str       )     ->		Optional[int]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(lowerCamelCase__						,lowerCamelCase__						,lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    List[str]       )     ->		Dict:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs_for_decoder()
           self.model_tester.create_and_check_model_as_decoder(lowerCamelCase__						,lowerCamelCase__						,lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[Any]       )     ->		List[str]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs_for_decoder()

           SCREAMING_SNAKE_CASE		=						None

           self.model_tester.create_and_check_model_as_decoder(lowerCamelCase__						,lowerCamelCase__						,lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    List[Any]       )     ->		List[str]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_decoder_model_past_large_inputs(lowerCamelCase__						,lowerCamelCase__						,lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Tuple       )     ->		List[str]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_causal_lm(*lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[int]       )     ->		Union[str, Any]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_question_answering(*lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Tuple       )     ->		Optional[Any]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_sequence_classification(*lowerCamelCase__       )






     def 				SCREAMING_SNAKE_CASE__  (							self						:    List[str]       )     ->		List[str]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_token_classification(*lowerCamelCase__       )






     @unittest.skip(reason="""Feed forward chunking is not implemented"""       )
     def 				SCREAMING_SNAKE_CASE__  (							self						:    Tuple       )     ->		Any:




           '''simple docstring'''


           pass






     @parameterized.expand([("""linear""",), ("""dynamic""",)]       )
     def 				SCREAMING_SNAKE_CASE__  (							self						:    Union[str, Any]						,lowerCamelCase__						:    int       )     ->		int:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs_for_common()
           SCREAMING_SNAKE_CASE		=						ids_tensor([1, 10]						,config.vocab_size       )
           SCREAMING_SNAKE_CASE		=						ids_tensor([1, int(config.max_position_embeddings * 1.5       )]						,config.vocab_size       )

           set_seed(42       )  # Fixed seed at init time so the two models get the same random weights
           SCREAMING_SNAKE_CASE		=						GPTNeoXModel(lowerCamelCase__       )
           original_model.to(lowerCamelCase__       )
           original_model.eval()
           SCREAMING_SNAKE_CASE		=						original_model(lowerCamelCase__       ).last_hidden_state
           SCREAMING_SNAKE_CASE		=						original_model(lowerCamelCase__       ).last_hidden_state

           set_seed(42       )  # Fixed seed at init time so the two models get the same random weights
           SCREAMING_SNAKE_CASE		=						{"""type""": scaling_type, """factor""": 10.0}
           SCREAMING_SNAKE_CASE		=						GPTNeoXModel(lowerCamelCase__       )
           scaled_model.to(lowerCamelCase__       )
           scaled_model.eval()
           SCREAMING_SNAKE_CASE		=						scaled_model(lowerCamelCase__       ).last_hidden_state
           SCREAMING_SNAKE_CASE		=						scaled_model(lowerCamelCase__       ).last_hidden_state

           # Dynamic scaling does not change the RoPE embeddings until it receives an input longer than the original
           # maximum sequence length, so the outputs for the short input should match.
           if scaling_type == "dynamic":
                 self.assertTrue(torch.allclose(lowerCamelCase__						,lowerCamelCase__						,atol=1e-5       )       )
           else:
                 self.assertFalse(torch.allclose(lowerCamelCase__						,lowerCamelCase__						,atol=1e-5       )       )

           # The output should be different for long inputs
           self.assertFalse(torch.allclose(lowerCamelCase__						,lowerCamelCase__						,atol=1e-5       )       )

@require_torch
class 		UpperCamelCase__ (      unittest.TestCase   ):



     '''simple docstring'''

     @slow
     def 				SCREAMING_SNAKE_CASE__  (							self						:    Any       )     ->		Optional[int]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						AutoTokenizer.from_pretrained("""EleutherAI/pythia-410m-deduped"""       )
           for checkpointing in [True, False]:
                 SCREAMING_SNAKE_CASE		=						GPTNeoXForCausalLM.from_pretrained("""EleutherAI/pythia-410m-deduped"""       )

                 if checkpointing:
                       model.gradient_checkpointing_enable()
                 else:
                       model.gradient_checkpointing_disable()
                 model.to(lowerCamelCase__       )

                 SCREAMING_SNAKE_CASE		=						tokenizer("""My favorite food is"""						,return_tensors="""pt"""       ).to(lowerCamelCase__       )
                 # The hub repo. is updated on 2023-04-04, resulting in poor outputs.
                 # See: https://github.com/huggingface/transformers/pull/24193
                 SCREAMING_SNAKE_CASE		=						"""My favorite food is a good old-fashioned, old-fashioned, old-fashioned.\n\nI'm not sure"""

                 SCREAMING_SNAKE_CASE		=						model.generate(**lowerCamelCase__						,do_sample=lowerCamelCase__						,max_new_tokens=20       )
                 SCREAMING_SNAKE_CASE		=						tokenizer.batch_decode(lowerCamelCase__       )[0]

                 self.assertEqual(lowerCamelCase__						,lowerCamelCase__       )









from collections import OrderedDict

from ...utils import logging
from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update
from .configuration_auto import CONFIG_MAPPING_NAMES


SCREAMING_SNAKE_CASE_						   =       logging.get_logger(__name__)


SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Base model mapping
        ("""albert""", """FlaxAlbertModel"""),
        ("""bart""", """FlaxBartModel"""),
        ("""beit""", """FlaxBeitModel"""),
        ("""bert""", """FlaxBertModel"""),
        ("""big_bird""", """FlaxBigBirdModel"""),
        ("""blenderbot""", """FlaxBlenderbotModel"""),
        ("""blenderbot-small""", """FlaxBlenderbotSmallModel"""),
        ("""clip""", """FlaxCLIPModel"""),
        ("""distilbert""", """FlaxDistilBertModel"""),
        ("""electra""", """FlaxElectraModel"""),
        ("""gpt-sw3""", """FlaxGPT2Model"""),
        ("""gpt2""", """FlaxGPT2Model"""),
        ("""gpt_neo""", """FlaxGPTNeoModel"""),
        ("""gptj""", """FlaxGPTJModel"""),
        ("""longt5""", """FlaxLongT5Model"""),
        ("""marian""", """FlaxMarianModel"""),
        ("""mbart""", """FlaxMBartModel"""),
        ("""mt5""", """FlaxMT5Model"""),
        ("""opt""", """FlaxOPTModel"""),
        ("""pegasus""", """FlaxPegasusModel"""),
        ("""regnet""", """FlaxRegNetModel"""),
        ("""resnet""", """FlaxResNetModel"""),
        ("""roberta""", """FlaxRobertaModel"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormModel"""),
        ("""roformer""", """FlaxRoFormerModel"""),
        ("""t5""", """FlaxT5Model"""),
        ("""vision-text-dual-encoder""", """FlaxVisionTextDualEncoderModel"""),
        ("""vit""", """FlaxViTModel"""),
        ("""wav2vec2""", """FlaxWav2Vec2Model"""),
        ("""whisper""", """FlaxWhisperModel"""),
        ("""xglm""", """FlaxXGLMModel"""),
        ("""xlm-roberta""", """FlaxXLMRobertaModel"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for pre-training mapping
        ("""albert""", """FlaxAlbertForPreTraining"""),
        ("""bart""", """FlaxBartForConditionalGeneration"""),
        ("""bert""", """FlaxBertForPreTraining"""),
        ("""big_bird""", """FlaxBigBirdForPreTraining"""),
        ("""electra""", """FlaxElectraForPreTraining"""),
        ("""longt5""", """FlaxLongT5ForConditionalGeneration"""),
        ("""mbart""", """FlaxMBartForConditionalGeneration"""),
        ("""mt5""", """FlaxMT5ForConditionalGeneration"""),
        ("""roberta""", """FlaxRobertaForMaskedLM"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForMaskedLM"""),
        ("""roformer""", """FlaxRoFormerForMaskedLM"""),
        ("""t5""", """FlaxT5ForConditionalGeneration"""),
        ("""wav2vec2""", """FlaxWav2Vec2ForPreTraining"""),
        ("""whisper""", """FlaxWhisperForConditionalGeneration"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForMaskedLM"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for Masked LM mapping
        ("""albert""", """FlaxAlbertForMaskedLM"""),
        ("""bart""", """FlaxBartForConditionalGeneration"""),
        ("""bert""", """FlaxBertForMaskedLM"""),
        ("""big_bird""", """FlaxBigBirdForMaskedLM"""),
        ("""distilbert""", """FlaxDistilBertForMaskedLM"""),
        ("""electra""", """FlaxElectraForMaskedLM"""),
        ("""mbart""", """FlaxMBartForConditionalGeneration"""),
        ("""roberta""", """FlaxRobertaForMaskedLM"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForMaskedLM"""),
        ("""roformer""", """FlaxRoFormerForMaskedLM"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForMaskedLM"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for Seq2Seq Causal LM mapping
        ("""bart""", """FlaxBartForConditionalGeneration"""),
        ("""blenderbot""", """FlaxBlenderbotForConditionalGeneration"""),
        ("""blenderbot-small""", """FlaxBlenderbotSmallForConditionalGeneration"""),
        ("""encoder-decoder""", """FlaxEncoderDecoderModel"""),
        ("""longt5""", """FlaxLongT5ForConditionalGeneration"""),
        ("""marian""", """FlaxMarianMTModel"""),
        ("""mbart""", """FlaxMBartForConditionalGeneration"""),
        ("""mt5""", """FlaxMT5ForConditionalGeneration"""),
        ("""pegasus""", """FlaxPegasusForConditionalGeneration"""),
        ("""t5""", """FlaxT5ForConditionalGeneration"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for Image-classsification
        ("""beit""", """FlaxBeitForImageClassification"""),
        ("""regnet""", """FlaxRegNetForImageClassification"""),
        ("""resnet""", """FlaxResNetForImageClassification"""),
        ("""vit""", """FlaxViTForImageClassification"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        ("""vision-encoder-decoder""", """FlaxVisionEncoderDecoderModel"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for Causal LM mapping
        ("""bart""", """FlaxBartForCausalLM"""),
        ("""bert""", """FlaxBertForCausalLM"""),
        ("""big_bird""", """FlaxBigBirdForCausalLM"""),
        ("""electra""", """FlaxElectraForCausalLM"""),
        ("""gpt-sw3""", """FlaxGPT2LMHeadModel"""),
        ("""gpt2""", """FlaxGPT2LMHeadModel"""),
        ("""gpt_neo""", """FlaxGPTNeoForCausalLM"""),
        ("""gptj""", """FlaxGPTJForCausalLM"""),
        ("""opt""", """FlaxOPTForCausalLM"""),
        ("""roberta""", """FlaxRobertaForCausalLM"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForCausalLM"""),
        ("""xglm""", """FlaxXGLMForCausalLM"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForCausalLM"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for Sequence Classification mapping
        ("""albert""", """FlaxAlbertForSequenceClassification"""),
        ("""bart""", """FlaxBartForSequenceClassification"""),
        ("""bert""", """FlaxBertForSequenceClassification"""),
        ("""big_bird""", """FlaxBigBirdForSequenceClassification"""),
        ("""distilbert""", """FlaxDistilBertForSequenceClassification"""),
        ("""electra""", """FlaxElectraForSequenceClassification"""),
        ("""mbart""", """FlaxMBartForSequenceClassification"""),
        ("""roberta""", """FlaxRobertaForSequenceClassification"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForSequenceClassification"""),
        ("""roformer""", """FlaxRoFormerForSequenceClassification"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForSequenceClassification"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for Question Answering mapping
        ("""albert""", """FlaxAlbertForQuestionAnswering"""),
        ("""bart""", """FlaxBartForQuestionAnswering"""),
        ("""bert""", """FlaxBertForQuestionAnswering"""),
        ("""big_bird""", """FlaxBigBirdForQuestionAnswering"""),
        ("""distilbert""", """FlaxDistilBertForQuestionAnswering"""),
        ("""electra""", """FlaxElectraForQuestionAnswering"""),
        ("""mbart""", """FlaxMBartForQuestionAnswering"""),
        ("""roberta""", """FlaxRobertaForQuestionAnswering"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForQuestionAnswering"""),
        ("""roformer""", """FlaxRoFormerForQuestionAnswering"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForQuestionAnswering"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for Token Classification mapping
        ("""albert""", """FlaxAlbertForTokenClassification"""),
        ("""bert""", """FlaxBertForTokenClassification"""),
        ("""big_bird""", """FlaxBigBirdForTokenClassification"""),
        ("""distilbert""", """FlaxDistilBertForTokenClassification"""),
        ("""electra""", """FlaxElectraForTokenClassification"""),
        ("""roberta""", """FlaxRobertaForTokenClassification"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForTokenClassification"""),
        ("""roformer""", """FlaxRoFormerForTokenClassification"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForTokenClassification"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        # Model for Multiple Choice mapping
        ("""albert""", """FlaxAlbertForMultipleChoice"""),
        ("""bert""", """FlaxBertForMultipleChoice"""),
        ("""big_bird""", """FlaxBigBirdForMultipleChoice"""),
        ("""distilbert""", """FlaxDistilBertForMultipleChoice"""),
        ("""electra""", """FlaxElectraForMultipleChoice"""),
        ("""roberta""", """FlaxRobertaForMultipleChoice"""),
        ("""roberta-prelayernorm""", """FlaxRobertaPreLayerNormForMultipleChoice"""),
        ("""roformer""", """FlaxRoFormerForMultipleChoice"""),
        ("""xlm-roberta""", """FlaxXLMRobertaForMultipleChoice"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        ("""bert""", """FlaxBertForNextSentencePrediction"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        ("""speech-encoder-decoder""", """FlaxSpeechEncoderDecoderModel"""),
        ("""whisper""", """FlaxWhisperForConditionalGeneration"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       OrderedDict(
    [
        ("""whisper""", """FlaxWhisperForAudioClassification"""),
    ]
)

SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_MAPPING_NAMES)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_PRETRAINING_MAPPING_NAMES)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_MASKED_LM_MAPPING_NAMES)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES
)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES
)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_CAUSAL_LM_MAPPING_NAMES)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES
)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES
)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES
)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING_NAMES
)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING_NAMES
)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES
)
SCREAMING_SNAKE_CASE_						   =       _LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES
)

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	List[str]			=			FLAX_MODEL_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(FlaxAutoModel)

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Dict			=			FLAX_MODEL_FOR_PRETRAINING_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(FlaxAutoModelForPreTraining, head_doc="""pretraining""")

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Optional[Any]			=			FLAX_MODEL_FOR_CAUSAL_LM_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(FlaxAutoModelForCausalLM, head_doc="""causal language modeling""")

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Any			=			FLAX_MODEL_FOR_MASKED_LM_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(FlaxAutoModelForMaskedLM, head_doc="""masked language modeling""")

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	int			=			FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(
    FlaxAutoModelForSeqaSeqLM, head_doc="""sequence-to-sequence language modeling""", checkpoint_for_example="""t5-base"""
)

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Optional[int]			=			FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(
    FlaxAutoModelForSequenceClassification, head_doc="""sequence classification"""
)

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	List[Any]			=			FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(FlaxAutoModelForQuestionAnswering, head_doc="""question answering""")

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Tuple			=			FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(
    FlaxAutoModelForTokenClassification, head_doc="""token classification"""
)

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Union[str, Any]			=			FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(FlaxAutoModelForMultipleChoice, head_doc="""multiple choice""")

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	List[str]			=			FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(
    FlaxAutoModelForNextSentencePrediction, head_doc="""next sentence prediction"""
)

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Dict			=			FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(
    FlaxAutoModelForImageClassification, head_doc="""image classification"""
)

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Dict			=			FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(FlaxAutoModelForVisionaSeq, head_doc="""vision-to-text modeling""")

class 		UpperCamelCase__ (      _BaseAutoModelClass   ):



     '''simple docstring'''

     __snake_case    :	Optional[Any]			=			FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING
SCREAMING_SNAKE_CASE_						   =       auto_class_update(
    FlaxAutoModelForSpeechSeqaSeq, head_doc="""sequence-to-sequence speech-to-text modeling"""
)


