




import unittest

from parameterized import parameterized

from transformers import LlamaConfig, 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 LlamaForCausalLM, LlamaForSequenceClassification, LlamaModel, LlamaTokenizer


class 				SCREAMING_SNAKE_CASE__ :





    def __init__(				self						,       a						,       a=13						,       a=7						,       a=True						,       a=True						,       a=False						,       a=True						,       a=99						,       a=32						,       a=5						,       a=4						,       a=37						,       a="gelu"						,       a=0.1						,       a=0.1						,       a=512						,       a=16						,       a=2						,       a=0.02						,       a=3						,       a=4						,       a=None						,       ):
         lowercase__   :       Any				=	parent
         lowercase__   :       Union[str, Any]				=	batch_size
         lowercase__   :       List[Any]				=	seq_length
         lowercase__   :       Dict				=	is_training
         lowercase__   :       Optional[Any]				=	use_input_mask
         lowercase__   :       Any				=	use_token_type_ids
         lowercase__   :       Optional[Any]				=	use_labels
         lowercase__   :       Tuple				=	vocab_size
         lowercase__   :       Optional[int]				=	hidden_size
         lowercase__   :       List[Any]				=	num_hidden_layers
         lowercase__   :       Optional[Any]				=	num_attention_heads
         lowercase__   :       Optional[int]				=	intermediate_size
         lowercase__   :       int				=	hidden_act
         lowercase__   :       Any				=	hidden_dropout_prob
         lowercase__   :       Union[str, Any]				=	attention_probs_dropout_prob
         lowercase__   :       Optional[Any]				=	max_position_embeddings
         lowercase__   :       Tuple				=	type_vocab_size
         lowercase__   :       List[Any]				=	type_sequence_label_size
         lowercase__   :       Optional[Any]				=	initializer_range
         lowercase__   :       str				=	num_labels
         lowercase__   :       List[Any]				=	num_choices
         lowercase__   :       Optional[int]				=	scope





    def 				snake_case_    (				self):
         lowercase__   :       Tuple				=	ids_tensor([self.batch_size, self.seq_length]						,       self.vocab_size)

         lowercase__   :       Optional[Any]				=	None
         if self.use_input_mask:
              lowercase__   :       int				=	random_attention_mask([self.batch_size, self.seq_length])

         lowercase__   :       Dict				=	None
         if self.use_token_type_ids:
              lowercase__   :       int				=	ids_tensor([self.batch_size, self.seq_length]						,       self.type_vocab_size)

         lowercase__   :       List[str]				=	None
         lowercase__   :       List[Any]				=	None
         lowercase__   :       str				=	None
         if self.use_labels:
              lowercase__   :       Any				=	ids_tensor([self.batch_size]						,       self.type_sequence_label_size)
              lowercase__   :       Dict				=	ids_tensor([self.batch_size, self.seq_length]						,       self.num_labels)
              lowercase__   :       Union[str, Any]				=	ids_tensor([self.batch_size]						,       self.num_choices)

         lowercase__   :       Union[str, Any]				=	self.get_config()

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels





    def 				snake_case_    (				self):
         return LlamaConfig(
             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=a						,       initializer_range=self.initializer_range						,       )





    def 				snake_case_    (				self						,       a						,       a						,       a						,       a						,       a						,       a						,       a):
         lowercase__   :       Any				=	LlamaModel(config=a)
         model.to(a)
         model.eval()
         lowercase__   :       str				=	model(a						,       attention_mask=a)
         lowercase__   :       Tuple				=	model(a)
         self.parent.assertEqual(result.last_hidden_state.shape						,       (self.batch_size, self.seq_length, self.hidden_size))





    def 				snake_case_    (				self						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       ):
         lowercase__   :       Optional[int]				=	True
         lowercase__   :       Dict				=	LlamaModel(a)
         model.to(a)
         model.eval()
         lowercase__   :       Dict				=	model(
             a						,       attention_mask=a						,       encoder_hidden_states=a						,       encoder_attention_mask=a						,       )
         lowercase__   :       Union[str, Any]				=	model(
             a						,       attention_mask=a						,       encoder_hidden_states=a						,       )
         lowercase__   :       Union[str, Any]				=	model(a						,       attention_mask=a)
         self.parent.assertEqual(result.last_hidden_state.shape						,       (self.batch_size, self.seq_length, self.hidden_size))





    def 				snake_case_    (				self						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       ):
         lowercase__   :       List[str]				=	LlamaForCausalLM(config=a)
         model.to(a)
         model.eval()
         lowercase__   :       Optional[Any]				=	model(a						,       attention_mask=a						,       labels=a)
         self.parent.assertEqual(result.logits.shape						,       (self.batch_size, self.seq_length, self.vocab_size))





    def 				snake_case_    (				self						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       a						,       ):
         lowercase__   :       Dict				=	True
         lowercase__   :       Optional[Any]				=	True
         lowercase__   :       int				=	LlamaForCausalLM(config=a)
         model.to(a)
         model.eval()

         # first forward pass
         lowercase__   :       str				=	model(
             a						,       attention_mask=a						,       encoder_hidden_states=a						,       encoder_attention_mask=a						,       use_cache=a						,       )
         lowercase__   :       Tuple				=	outputs.past_key_values

         # create hypothetical multiple next token and extent to next_input_ids
         lowercase__   :       Optional[int]				=	ids_tensor((self.batch_size, 3)						,       config.vocab_size)
         lowercase__   :       str				=	ids_tensor((self.batch_size, 3)						,       vocab_size=2)

         # append to next input_ids and
         lowercase__   :       Union[str, Any]				=	torch.cat([input_ids, next_tokens]						,       dim=-1)
         lowercase__   :       Dict				=	torch.cat([input_mask, next_mask]						,       dim=-1)

         lowercase__   :       Optional[int]				=	model(
             a						,       attention_mask=a						,       encoder_hidden_states=a						,       encoder_attention_mask=a						,       output_hidden_states=a						,       )['hidden_states'][0]
         lowercase__   :       Any				=	model(
             a						,       attention_mask=a						,       encoder_hidden_states=a						,       encoder_attention_mask=a						,       past_key_values=a						,       output_hidden_states=a						,       )['hidden_states'][0]

         # select random slice
         lowercase__   :       str				=	ids_tensor((1,)						,       output_from_past.shape[-1]).item()
         lowercase__   :       Optional[Any]				=	output_from_no_past[:, -3:, random_slice_idx].detach()
         lowercase__   :       List[Any]				=	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(a						,       a						,       atol=1e-3))





    def 				snake_case_    (				self):
         lowercase__   :       Tuple				=	self.prepare_config_and_inputs()
         (
             lowercase__			
         )   :       Tuple				=	config_and_inputs
         lowercase__   :       Tuple				=	{'input_ids': input_ids, 'attention_mask': input_mask}
         return config, inputs_dict



@require_torch
class 				SCREAMING_SNAKE_CASE__ (__snake_case		,	__snake_case		,	__snake_case		,	unittest.TestCase					):
    __lowerCamelCase						:	Optional[int]														=					(LlamaModel, LlamaForCausalLM, LlamaForSequenceClassification) if is_torch_available() else ()
    __lowerCamelCase						:	Any														=					(LlamaForCausalLM,) if is_torch_available() else ()
    __lowerCamelCase						:	Dict														=					(
        {
            """feature-extraction""": LlamaModel,
            """text-classification""": LlamaForSequenceClassification,
            """text-generation""": LlamaForCausalLM,
            """zero-shot""": LlamaForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )
    __lowerCamelCase						:	int														=					False
    __lowerCamelCase						:	Union[str, Any]														=					False





    def 				snake_case_    (				self):
         lowercase__   :       str				=	LlamaModelTester(self)
         lowercase__   :       Tuple				=	ConfigTester(self						,       config_class=a						,       hidden_size=37)





    def 				snake_case_    (				self):
         self.config_tester.run_common_tests()





    def 				snake_case_    (				self):
         lowercase__   :       List[str]				=	self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*a)





    def 				snake_case_    (				self):
         lowercase__   :       str				=	self.model_tester.prepare_config_and_inputs()
         for type in ["absolute", "relative_key", "relative_key_query"]:
              lowercase__   :       Tuple				=	type
              self.model_tester.create_and_check_model(*a)





    def 				snake_case_    (				self):
         lowercase__   :       Dict				=	self.model_tester.prepare_config_and_inputs_for_common()
         lowercase__   :       Any				=	3
         lowercase__   :       str				=	input_dict['input_ids']
         lowercase__   :       str				=	input_ids.ne(1).to(a)
         lowercase__   :       List[Any]				=	ids_tensor([self.model_tester.batch_size]						,       self.model_tester.type_sequence_label_size)
         lowercase__   :       int				=	LlamaForSequenceClassification(a)
         model.to(a)
         model.eval()
         lowercase__   :       int				=	model(a						,       attention_mask=a						,       labels=a)
         self.assertEqual(result.logits.shape						,       (self.model_tester.batch_size, self.model_tester.num_labels))





    def 				snake_case_    (				self):
         lowercase__   :       List[str]				=	self.model_tester.prepare_config_and_inputs_for_common()
         lowercase__   :       Tuple				=	3
         lowercase__   :       Optional[int]				=	'single_label_classification'
         lowercase__   :       Union[str, Any]				=	input_dict['input_ids']
         lowercase__   :       int				=	input_ids.ne(1).to(a)
         lowercase__   :       List[str]				=	ids_tensor([self.model_tester.batch_size]						,       self.model_tester.type_sequence_label_size)
         lowercase__   :       int				=	LlamaForSequenceClassification(a)
         model.to(a)
         model.eval()
         lowercase__   :       str				=	model(a						,       attention_mask=a						,       labels=a)
         self.assertEqual(result.logits.shape						,       (self.model_tester.batch_size, self.model_tester.num_labels))





    def 				snake_case_    (				self):
         lowercase__   :       str				=	self.model_tester.prepare_config_and_inputs_for_common()
         lowercase__   :       Any				=	3
         lowercase__   :       Any				=	'multi_label_classification'
         lowercase__   :       int				=	input_dict['input_ids']
         lowercase__   :       Optional[int]				=	input_ids.ne(1).to(a)
         lowercase__   :       Dict				=	ids_tensor(
             [self.model_tester.batch_size, config.num_labels]						,       self.model_tester.type_sequence_label_size).to(torch.float)
         lowercase__   :       Tuple				=	LlamaForSequenceClassification(a)
         model.to(a)
         model.eval()
         lowercase__   :       int				=	model(a						,       attention_mask=a						,       labels=a)
         self.assertEqual(result.logits.shape						,       (self.model_tester.batch_size, self.model_tester.num_labels))





    @unittest.skip('LLaMA buffers include complex numbers, which breaks this test')
    def 				snake_case_    (				self):
         pass





    @parameterized.expand([('linear',), ('dynamic',)])
    def 				snake_case_    (				self						,       a):
         lowercase__   :       Dict				=	self.model_tester.prepare_config_and_inputs_for_common()
         lowercase__   :       List[Any]				=	ids_tensor([1, 10]						,       config.vocab_size)
         lowercase__   :       Union[str, Any]				=	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
         lowercase__   :       Tuple				=	LlamaModel(a)
         original_model.to(a)
         original_model.eval()
         lowercase__   :       List[str]				=	original_model(a).last_hidden_state
         lowercase__   :       int				=	original_model(a).last_hidden_state

         set_seed(42)  # Fixed seed at init time so the two models get the same random weights
         lowercase__   :       Union[str, Any]				=	{'type': scaling_type, 'factor': 10.0}
         lowercase__   :       int				=	LlamaModel(a)
         scaled_model.to(a)
         scaled_model.eval()
         lowercase__   :       int				=	scaled_model(a).last_hidden_state
         lowercase__   :       Dict				=	scaled_model(a).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(a						,       a						,       atol=1e-5))
         else:
              self.assertFalse(torch.allclose(a						,       a						,       atol=1e-5))

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



@require_torch
class 				SCREAMING_SNAKE_CASE__ (unittest.TestCase					):





    @unittest.skip('Logits are not exactly the same, once we fix the instabalities somehow, will update!')
    @slow
    def 				snake_case_    (				self):
         lowercase__   :       Any				=	[1, 306, 4658, 278, 6593, 310, 2834, 338]
         lowercase__   :       List[Any]				=	LlamaForCausalLM.from_pretrained('meta-llama/Llama-2-7b-hf'						,       device_map='auto')
         lowercase__   :       Optional[int]				=	model(torch.tensor([input_ids]))
         # Expected mean on dim = -1
         lowercase__   :       Tuple				=	torch.tensor([[-6.6_550, -4.1_227, -4.9_859, -3.2_406, 0.8_262, -3.0_033, 1.2_964, -3.3_699]])
         torch.testing.assert_close(out.mean(-1)						,       a						,       atol=1e-2						,       rtol=1e-2)
         # slicing logits[0, 0, 0:30]
         # fmt: off
         lowercase__   :       List[str]				=	torch.tensor([-12.8_281, -7.4_453, -0.4_639, -8.0_625, -7.2_500, -8.0_000, -6.4_883, -7.7_695, -7.8_438, -7.0_312, -6.2_188, -7.1_328, -1.8_496, 1.9_961, -8.6_250, -6.7_227, -12.8_281, -6.9_492, -7.0_742, -7.7_852, -7.5_820, -7.9_062, -6.9_375, -7.9_805, -8.3_438, -8.1_562, -8.0_469, -7.6_250, -7.7_422, -7.3_398,])
         # fmt: on
         torch.testing.assert_close(out[0, 0, :30]						,       a						,       atol=1e-5						,       rtol=1e-5)





    @unittest.skip('Logits are not exactly the same, once we fix the instabalities somehow, will update!')
    @slow
    def 				snake_case_    (				self):
         lowercase__   :       Dict				=	[1, 306, 4658, 278, 6593, 310, 2834, 338]
         lowercase__   :       List[Any]				=	LlamaForCausalLM.from_pretrained('meta-llama/Llama-2-13b-hf'						,       device_map='auto')
         lowercase__   :       Dict				=	model(torch.tensor(a))
         # Expected mean on dim = -1
         lowercase__   :       List[str]				=	torch.tensor([[-2.0_622, -1.2_794, -1.1_638, -0.9_788, -1.4_603, -1.0_238, -1.7_893, -1.4_411]])
         torch.testing.assert_close(out.mean(-1)						,       a						,       atol=1e-2						,       rtol=1e-2)
         # slicing logits[0, 0, 0:30]
         # fmt: off
         lowercase__   :       Union[str, Any]				=	torch.tensor([-8.1_406, -8.0_547, 2.7_461, -1.2_344, -0.1_448, -1.8_262, -1.0_020, -1.8_154, -1.6_895, -1.8_516, -2.3_574, -0.9_277, 3.7_598, 6.5_742, -1.2_998, -0.1_177, -8.1_406, -2.9_688, -2.9_199, -3.1_699, -3.5_254, -2.3_555, -2.7_988, -3.4_141, -2.8_262, -4.5_195, -3.3_379, -3.3_164, -2.7_832, -3.0_273])
         # fmt: on
         torch.testing.assert_close(out[0, 0, :30]						,       a						,       atol=1e-5						,       rtol=1e-5)





    @unittest.skip('Logits are not exactly the same, once we fix the instabalities somehow, will update!')
    @slow
    def 				snake_case_    (				self):
         lowercase__   :       Tuple				=	[1, 306, 4658, 278, 6593, 310, 2834, 338]
         lowercase__   :       Tuple				=	LlamaForCausalLM.from_pretrained('meta-llama/Llama-2-13b-chat-hf'						,       device_map='auto')
         lowercase__   :       Optional[int]				=	model(torch.tensor(a))
         # Expected mean on dim = -1
         lowercase__   :       Dict				=	torch.tensor([[-0.8_562, -1.8_520, -0.7_551, -0.4_162, -1.5_161, -1.2_038, -2.4_823, -2.3_254]])
         torch.testing.assert_close(out.mean(-1)						,       a						,       atol=1e-2						,       rtol=1e-2)
         # slicing logits[0, 0, 0:30]
         # fmt: off
         lowercase__   :       Tuple				=	torch.tensor([-2.2_227, 4.8_828, 0.9_023, -0.4_578, -0.7_871, -0.1_033, -0.6_221, -0.5_786, -0.7_803, -1.0_674, -1.2_920, -0.1_570, 0.8_008, 2.0_723, -0.9_497, 0.2_771, -2.2_227, -0.7_612, -1.4_346, -1.2_061, -1.6_426, -0.3_000, -0.7_139, -1.1_934, -1.8_691, -1.6_973, -1.5_947, -1.2_705, -0.3_523, -0.5_513])
         # fmt: on
         torch.testing.assert_close(out.mean(-1)						,       a						,       atol=1e-2						,       rtol=1e-2)





    @unittest.skip(
        'Logits are not exactly the same, once we fix the instabalities somehow, will update! Also it is gonna be a `too_slow` test')
    @slow
    def 				snake_case_    (				self):
         lowercase__   :       Union[str, Any]				=	[1, 306, 4658, 278, 6593, 310, 2834, 338]
         lowercase__   :       Optional[Any]				=	LlamaForCausalLM.from_pretrained('meta-llama/Llama-2-70b-hf'						,       device_map='auto')
         lowercase__   :       str				=	model(torch.tensor(a))

         lowercase__   :       Any				=	torch.tensor(
             [[-4.2_327, -3.3_360, -4.6_665, -4.7_631, -1.8_180, -3.4_170, -1.4_211, -3.1_810]]						,       dtype=torch.floataa)
         torch.testing.assert_close(out.mean(-1)						,       a						,       atol=1e-2						,       rtol=1e-2)
         # fmt: off
         lowercase__   :       Union[str, Any]				=	torch.tensor([-9.4_922, -3.9_551, 1.7_998, -5.6_758, -5.1_055, -5.8_984, -4.8_320, -6.8_086, -6.5_391, -5.6_172, -5.5_820, -5.5_352, 1.7_881, 3.6_289, -6.5_117, -3.4_785, -9.5_000, -6.0_352, -6.8_125, -6.0_195, -6.6_836, -5.4_727, -6.2_812, -6.0_391, -7.3_398, -7.4_297, -7.4_844, -6.5_820, -5.8_789, -5.5_312])
         # fmt: on
         torch.testing.assert_close(out[0, 0, :30]						,       a						,       atol=1e-5						,       rtol=1e-5)





    @unittest.skip('Model is curently gated')
    @slow
    def 				snake_case_    (				self):
         lowercase__   :       Tuple				=	'Simply put, the theory of relativity states that 1) the laws of physics are the same everywhere in the universe and 2) the passage of time and the length of objects can vary depending on the observer\'s frame of reference.\n\nThe first part of the theory, that the laws of physics are the same everywhere, is known as the "princi'
         lowercase__   :       Tuple				=	'Simply put, the theory of relativity states that '
         lowercase__   :       Dict				=	LlamaTokenizer.from_pretrained('meta-llama/Llama-2-13b-chat-hf')
         lowercase__   :       List[str]				=	tokenizer.encode(a						,       return_tensors='pt')
         lowercase__   :       Union[str, Any]				=	LlamaForCausalLM.from_pretrained(
             'meta-llama/Llama-2-13b-chat-hf'						,       device_map='sequential'						,       use_safetensors=a)

         # greedy generation outputs
         lowercase__   :       int				=	model.generate(a						,       max_new_tokens=64						,       top_p=a						,       temperature=1						,       do_sample=a)
         lowercase__   :       Any				=	tokenizer.decode(generated_ids[0]						,       skip_special_tokens=a)
         self.assertEqual(a						,       a)




from collections import OrderedDict

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


snake_case_        =			logging.get_logger(__name__)


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'''),
    ]
)

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'''),
    ]
)

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'''),
    ]
)

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'''),
    ]
)

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

snake_case_        =			OrderedDict(
    [
        ('''vision-encoder-decoder''', '''FlaxVisionEncoderDecoderModel'''),
    ]
)

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'''),
    ]
)

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'''),
    ]
)

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'''),
    ]
)

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'''),
    ]
)

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'''),
    ]
)

snake_case_        =			OrderedDict(
    [
        ('''bert''', '''FlaxBertForNextSentencePrediction'''),
    ]
)

snake_case_        =			OrderedDict(
    [
        ('''speech-encoder-decoder''', '''FlaxSpeechEncoderDecoderModel'''),
        ('''whisper''', '''FlaxWhisperForConditionalGeneration'''),
    ]
)

snake_case_        =			OrderedDict(
    [
        ('''whisper''', '''FlaxWhisperForAudioClassification'''),
    ]
)

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


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	str														=					FLAX_MODEL_MAPPING



snake_case_        =			auto_class_update(FlaxAutoModel)


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Dict														=					FLAX_MODEL_FOR_PRETRAINING_MAPPING



snake_case_        =			auto_class_update(FlaxAutoModelForPreTraining, head_doc='''pretraining''')


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	List[Any]														=					FLAX_MODEL_FOR_CAUSAL_LM_MAPPING



snake_case_        =			auto_class_update(FlaxAutoModelForCausalLM, head_doc='''causal language modeling''')


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Optional[int]														=					FLAX_MODEL_FOR_MASKED_LM_MAPPING



snake_case_        =			auto_class_update(FlaxAutoModelForMaskedLM, head_doc='''masked language modeling''')


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Optional[int]														=					FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING



snake_case_        =			auto_class_update(
    FlaxAutoModelForSeqaSeqLM, head_doc='''sequence-to-sequence language modeling''', checkpoint_for_example='''t5-base'''
)


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Dict														=					FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING



snake_case_        =			auto_class_update(
    FlaxAutoModelForSequenceClassification, head_doc='''sequence classification'''
)


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Tuple														=					FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING



snake_case_        =			auto_class_update(FlaxAutoModelForQuestionAnswering, head_doc='''question answering''')


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Tuple														=					FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING



snake_case_        =			auto_class_update(
    FlaxAutoModelForTokenClassification, head_doc='''token classification'''
)


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	str														=					FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING



snake_case_        =			auto_class_update(FlaxAutoModelForMultipleChoice, head_doc='''multiple choice''')


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Union[str, Any]														=					FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING



snake_case_        =			auto_class_update(
    FlaxAutoModelForNextSentencePrediction, head_doc='''next sentence prediction'''
)


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Union[str, Any]														=					FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING



snake_case_        =			auto_class_update(
    FlaxAutoModelForImageClassification, head_doc='''image classification'''
)


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	Tuple														=					FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING



snake_case_        =			auto_class_update(FlaxAutoModelForVisionaSeq, head_doc='''vision-to-text modeling''')


class 				SCREAMING_SNAKE_CASE__ (_BaseAutoModelClass					):
    __lowerCamelCase						:	List[str]														=					FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING



snake_case_        =			auto_class_update(
    FlaxAutoModelForSpeechSeqaSeq, head_doc='''sequence-to-sequence speech-to-text modeling'''
)

