


from typing import Optional

import torch
import torch.utils.checkpoint
from torch import Tensor, nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_outputs import (
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import logging
from .configuration_regnet import RegNetConfig


lowerCamelCase						=		logging.get_logger(__name__)

# General docstring
lowerCamelCase						=		'''RegNetConfig'''

# Base docstring
lowerCamelCase						=		'''facebook/regnet-y-040'''
lowerCamelCase						=		[1, 1088, 7, 7]

# Image classification docstring
lowerCamelCase						=		'''facebook/regnet-y-040'''
lowerCamelCase						=		'''tabby, tabby cat'''

lowerCamelCase						=		[
    '''facebook/regnet-y-040''',
    # See all regnet models at https://huggingface.co/models?filter=regnet
]





class  _a							(    nn.Module):




	def __init__( self						:		List[Any]		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int = 3		, _SCREAMING_SNAKE_CASE						:		int = 1		, _SCREAMING_SNAKE_CASE						:		int = 1		, _SCREAMING_SNAKE_CASE						:		Optional[str] = "relu"		, )->	Optional[int]:
			super().__init__()
			lowerCAmelCase__       :      List[Any]   					= nn.Convad(
			    _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, kernel_size=_SCREAMING_SNAKE_CASE		, stride=_SCREAMING_SNAKE_CASE		, padding=kernel_size // 2		, groups=_SCREAMING_SNAKE_CASE		, bias=_SCREAMING_SNAKE_CASE		, )
			lowerCAmelCase__       :      str   					= nn.BatchNormad(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      List[Any]   					= ACTaFN[activation] if activation is not None else nn.Identity()




	def 							UpperCAmelCase__( self						:		Optional[Any]		, _SCREAMING_SNAKE_CASE						:		Any		)->	Optional[int]:
			lowerCAmelCase__       :      Tuple   					= self.convolution(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Any   					= self.normalization(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Any   					= self.activation(_SCREAMING_SNAKE_CASE		)
			return hidden_state





class  _a							(    nn.Module):




	def __init__( self						:		Union[str, Any]		, _SCREAMING_SNAKE_CASE						:		RegNetConfig		)->	Optional[Any]:
			super().__init__()
			lowerCAmelCase__       :      List[Any]   					= RegNetConvLayer(
			    config.num_channels		, config.embedding_size		, kernel_size=3		, stride=2		, activation=config.hidden_act		)
			lowerCAmelCase__       :      List[Any]   					= config.num_channels




	def 							UpperCAmelCase__( self						:		Tuple		, _SCREAMING_SNAKE_CASE						:		Optional[int]		)->	Dict:
			lowerCAmelCase__       :      List[str]   					= pixel_values.shape[1]
			if num_channels != self.num_channels:
					raise ValueError(
					    '''Make sure that the channel dimension of the pixel values match with the one set in the configuration.'''		)
			lowerCAmelCase__       :      Dict   					= self.embedder(_SCREAMING_SNAKE_CASE		)
			return hidden_state





class  _a							(    nn.Module):




	def __init__( self						:		str		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int = 2		)->	List[Any]:
			super().__init__()
			lowerCAmelCase__       :      str   					= nn.Convad(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, kernel_size=1		, stride=_SCREAMING_SNAKE_CASE		, bias=_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Any   					= nn.BatchNormad(_SCREAMING_SNAKE_CASE		)




	def 							UpperCAmelCase__( self						:		Union[str, Any]		, _SCREAMING_SNAKE_CASE						:		Tensor		)->	Tensor:
			lowerCAmelCase__       :      int   					= self.convolution(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Any   					= self.normalization(_SCREAMING_SNAKE_CASE		)
			return hidden_state





class  _a							(    nn.Module):




	def __init__( self						:		Tuple		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int		)->	List[Any]:
			super().__init__()

			lowerCAmelCase__       :      List[Any]   					= nn.AdaptiveAvgPoolad((1, 1)		)
			lowerCAmelCase__       :      str   					= nn.Sequential(
			    nn.Convad(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, kernel_size=1		)		, nn.ReLU()		, nn.Convad(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, kernel_size=1		)		, nn.Sigmoid()		, )




	def 							UpperCAmelCase__( self						:		Dict		, _SCREAMING_SNAKE_CASE						:		List[str]		)->	List[str]:
			# b c h w -> b c 1 1
			lowerCAmelCase__       :      Optional[Any]   					= self.pooler(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Optional[int]   					= self.attention(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Optional[int]   					= hidden_state * attention
			return hidden_state





class  _a							(    nn.Module):




	def __init__( self						:		Optional[int]		, _SCREAMING_SNAKE_CASE						:		RegNetConfig		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int = 1		)->	str:
			super().__init__()
			lowerCAmelCase__       :      int   					= in_channels != out_channels or stride != 1
			lowerCAmelCase__       :      List[Any]   					= max(1		, out_channels // config.groups_width		)
			lowerCAmelCase__       :      List[Any]   					= (
			    RegNetShortCut(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, stride=_SCREAMING_SNAKE_CASE		) if should_apply_shortcut else nn.Identity()
			)
			lowerCAmelCase__       :      Union[str, Any]   					= nn.Sequential(
			    RegNetConvLayer(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, kernel_size=1		, activation=config.hidden_act		)		, RegNetConvLayer(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, stride=_SCREAMING_SNAKE_CASE		, groups=_SCREAMING_SNAKE_CASE		, activation=config.hidden_act		)		, RegNetConvLayer(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, kernel_size=1		, activation=_SCREAMING_SNAKE_CASE		)		, )
			lowerCAmelCase__       :      Optional[Any]   					= ACTaFN[config.hidden_act]




	def 							UpperCAmelCase__( self						:		List[str]		, _SCREAMING_SNAKE_CASE						:		int		)->	Optional[Any]:
			lowerCAmelCase__       :      Optional[Any]   					= hidden_state
			lowerCAmelCase__       :      List[str]   					= self.layer(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Optional[Any]   					= self.shortcut(_SCREAMING_SNAKE_CASE		)
			hidden_state += residual
			lowerCAmelCase__       :      str   					= self.activation(_SCREAMING_SNAKE_CASE		)
			return hidden_state





class  _a							(    nn.Module):




	def __init__( self						:		List[Any]		, _SCREAMING_SNAKE_CASE						:		RegNetConfig		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int = 1		)->	Optional[int]:
			super().__init__()
			lowerCAmelCase__       :      Optional[int]   					= in_channels != out_channels or stride != 1
			lowerCAmelCase__       :      List[str]   					= max(1		, out_channels // config.groups_width		)
			lowerCAmelCase__       :      Any   					= (
			    RegNetShortCut(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, stride=_SCREAMING_SNAKE_CASE		) if should_apply_shortcut else nn.Identity()
			)
			lowerCAmelCase__       :      Tuple   					= nn.Sequential(
			    RegNetConvLayer(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, kernel_size=1		, activation=config.hidden_act		)		, RegNetConvLayer(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, stride=_SCREAMING_SNAKE_CASE		, groups=_SCREAMING_SNAKE_CASE		, activation=config.hidden_act		)		, RegNetSELayer(_SCREAMING_SNAKE_CASE		, reduced_channels=int(round(in_channels / 4		)		)		)		, RegNetConvLayer(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, kernel_size=1		, activation=_SCREAMING_SNAKE_CASE		)		, )
			lowerCAmelCase__       :      Tuple   					= ACTaFN[config.hidden_act]




	def 							UpperCAmelCase__( self						:		int		, _SCREAMING_SNAKE_CASE						:		Union[str, Any]		)->	List[str]:
			lowerCAmelCase__       :      Optional[int]   					= hidden_state
			lowerCAmelCase__       :      Optional[Any]   					= self.layer(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Optional[int]   					= self.shortcut(_SCREAMING_SNAKE_CASE		)
			hidden_state += residual
			lowerCAmelCase__       :      List[Any]   					= self.activation(_SCREAMING_SNAKE_CASE		)
			return hidden_state





class  _a							(    nn.Module):




	def __init__( self						:		Union[str, Any]		, _SCREAMING_SNAKE_CASE						:		RegNetConfig		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int		, _SCREAMING_SNAKE_CASE						:		int = 2		, _SCREAMING_SNAKE_CASE						:		int = 2		, )->	int:
			super().__init__()

			lowerCAmelCase__       :      List[str]   					= RegNetXLayer if config.layer_type == '''x''' else RegNetYLayer

			lowerCAmelCase__       :      Optional[int]   					= nn.Sequential(
			    # downsampling is done in the first layer with stride of 2
			    layer(
			        _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, stride=_SCREAMING_SNAKE_CASE		, )		, *[layer(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		) for _ in range(depth - 1		)]		, )




	def 							UpperCAmelCase__( self						:		Tuple		, _SCREAMING_SNAKE_CASE						:		str		)->	Dict:
			lowerCAmelCase__       :      Union[str, Any]   					= self.layers(_SCREAMING_SNAKE_CASE		)
			return hidden_state





class  _a							(    nn.Module):




	def __init__( self						:		List[Any]		, _SCREAMING_SNAKE_CASE						:		RegNetConfig		)->	List[Any]:
			super().__init__()
			lowerCAmelCase__       :      str   					= nn.ModuleList([]		)
			# based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
			self.stages.append(
			    RegNetStage(
			        _SCREAMING_SNAKE_CASE		, config.embedding_size		, config.hidden_sizes[0]		, stride=2 if config.downsample_in_first_stage else 1		, depth=config.depths[0]		, )		)
			lowerCAmelCase__       :      Any   					= zip(config.hidden_sizes		, config.hidden_sizes[1:]		)
			for (in_channels, out_channels), depth in zip(_SCREAMING_SNAKE_CASE		, config.depths[1:]		):
					self.stages.append(RegNetStage(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, depth=_SCREAMING_SNAKE_CASE		)		)




	def 							UpperCAmelCase__( self						:		List[Any]		, _SCREAMING_SNAKE_CASE						:		Tensor		, _SCREAMING_SNAKE_CASE						:		bool = False		, _SCREAMING_SNAKE_CASE						:		bool = True		)->	BaseModelOutputWithNoAttention:
			lowerCAmelCase__       :      Optional[Any]   					= () if output_hidden_states else None

			for stage_module in self.stages:
					if output_hidden_states:
							lowerCAmelCase__       :      int   					= hidden_states + (hidden_state,)

					lowerCAmelCase__       :      Optional[int]   					= stage_module(_SCREAMING_SNAKE_CASE		)

			if output_hidden_states:
					lowerCAmelCase__       :      List[str]   					= hidden_states + (hidden_state,)

			if not return_dict:
					return tuple(v for v in [hidden_state, hidden_states] if v is not None		)

			return BaseModelOutputWithNoAttention(last_hidden_state=_SCREAMING_SNAKE_CASE		, hidden_states=_SCREAMING_SNAKE_CASE		)





class  _a							(    _lowercase):
	_a  :  int				   =							RegNetConfig
	_a  :  List[Any]				   =							'''regnet'''
	_a  :  Optional[Any]				   =							'''pixel_values'''
	_a  :  Dict				   =							True




	def 							UpperCAmelCase__( self						:		int		, _SCREAMING_SNAKE_CASE						:		str		)->	Tuple:
			if isinstance(_SCREAMING_SNAKE_CASE		, nn.Convad		):
					nn.init.kaiming_normal_(module.weight		, mode='''fan_out'''		, nonlinearity='''relu'''		)
			elif isinstance(_SCREAMING_SNAKE_CASE		, (nn.BatchNormad, nn.GroupNorm)		):
					nn.init.constant_(module.weight		, 1		)
					nn.init.constant_(module.bias		, 0		)




	def 							UpperCAmelCase__( self						:		List[str]		, _SCREAMING_SNAKE_CASE						:		Union[str, Any]		, _SCREAMING_SNAKE_CASE						:		List[str]=False		)->	Optional[int]:
			if isinstance(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		):
					lowerCAmelCase__       :      Union[str, Any]   					= value
lowerCamelCase						=		R'''
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it
    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`RegNetConfig`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
'''

lowerCamelCase						=		R'''
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`ConvNextImageProcessor.__call__`] for details.

        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.
'''





@add_start_docstrings(
    '''The bare RegNet model outputting raw features without any specific head on top.'''					,						_lowercase					,						)
# Copied from transformers.models.resnet.modeling_resnet.ResNetModel with RESNET->REGNET,ResNet->RegNet
class  _a							(    _lowercase):




	def __init__( self						:		Tuple		, _SCREAMING_SNAKE_CASE						:		Any		)->	Union[str, Any]:
			super().__init__(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Dict   					= config
			lowerCAmelCase__       :      Any   					= RegNetEmbeddings(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Optional[int]   					= RegNetEncoder(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      int   					= nn.AdaptiveAvgPoolad((1, 1)		)
			# Initialize weights and apply final processing
			self.post_init()




	@add_start_docstrings_to_model_forward(_SCREAMING_SNAKE_CASE		)
	@add_code_sample_docstrings(
	    checkpoint=_CHECKPOINT_FOR_DOC		, output_type=_SCREAMING_SNAKE_CASE		, config_class=_CONFIG_FOR_DOC		, modality='''vision'''		, expected_output=_EXPECTED_OUTPUT_SHAPE		, )
	def 							UpperCAmelCase__( self						:		Union[str, Any]		, _SCREAMING_SNAKE_CASE						:		Tensor		, _SCREAMING_SNAKE_CASE						:		Optional[bool] = None		, _SCREAMING_SNAKE_CASE						:		Optional[bool] = None		)->	BaseModelOutputWithPoolingAndNoAttention:
			lowerCAmelCase__       :      Optional[int]   					= (
			    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
			)
			lowerCAmelCase__       :      Optional[int]   					= return_dict if return_dict is not None else self.config.use_return_dict

			lowerCAmelCase__       :      List[Any]   					= self.embedder(_SCREAMING_SNAKE_CASE		)

			lowerCAmelCase__       :      Optional[int]   					= self.encoder(
			    _SCREAMING_SNAKE_CASE		, output_hidden_states=_SCREAMING_SNAKE_CASE		, return_dict=_SCREAMING_SNAKE_CASE		)

			lowerCAmelCase__       :      Union[str, Any]   					= encoder_outputs[0]

			lowerCAmelCase__       :      List[str]   					= self.pooler(_SCREAMING_SNAKE_CASE		)

			if not return_dict:
					return (last_hidden_state, pooled_output) + encoder_outputs[1:]

			return BaseModelOutputWithPoolingAndNoAttention(
			    last_hidden_state=_SCREAMING_SNAKE_CASE		, pooler_output=_SCREAMING_SNAKE_CASE		, hidden_states=encoder_outputs.hidden_states		, )





@add_start_docstrings(
    '''
    RegNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for
    ImageNet.
    '''					,						_lowercase					,						)
# Copied from transformers.models.resnet.modeling_resnet.ResNetForImageClassification with RESNET->REGNET,ResNet->RegNet,resnet->regnet
class  _a							(    _lowercase):




	def __init__( self						:		Dict		, _SCREAMING_SNAKE_CASE						:		List[Any]		)->	str:
			super().__init__(_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      Union[str, Any]   					= config.num_labels
			lowerCAmelCase__       :      Optional[Any]   					= RegNetModel(_SCREAMING_SNAKE_CASE		)
			# classification head
			lowerCAmelCase__       :      List[str]   					= nn.Sequential(
			    nn.Flatten()		, nn.Linear(config.hidden_sizes[-1]		, config.num_labels		) if config.num_labels > 0 else nn.Identity()		, )
			# initialize weights and apply final processing
			self.post_init()




	@add_start_docstrings_to_model_forward(_SCREAMING_SNAKE_CASE		)
	@add_code_sample_docstrings(
	    checkpoint=_IMAGE_CLASS_CHECKPOINT		, output_type=_SCREAMING_SNAKE_CASE		, config_class=_CONFIG_FOR_DOC		, expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT		, )
	def 							UpperCAmelCase__( self						:		List[Any]		, _SCREAMING_SNAKE_CASE						:		Optional[torch.FloatTensor] = None		, _SCREAMING_SNAKE_CASE						:		Optional[torch.LongTensor] = None		, _SCREAMING_SNAKE_CASE						:		Optional[bool] = None		, _SCREAMING_SNAKE_CASE						:		Optional[bool] = None		, )->	ImageClassifierOutputWithNoAttention:
			lowerCAmelCase__       :      str   					= return_dict if return_dict is not None else self.config.use_return_dict

			lowerCAmelCase__       :      Optional[Any]   					= self.regnet(_SCREAMING_SNAKE_CASE		, output_hidden_states=_SCREAMING_SNAKE_CASE		, return_dict=_SCREAMING_SNAKE_CASE		)

			lowerCAmelCase__       :      Union[str, Any]   					= outputs.pooler_output if return_dict else outputs[1]

			lowerCAmelCase__       :      Optional[Any]   					= self.classifier(_SCREAMING_SNAKE_CASE		)

			lowerCAmelCase__       :      List[str]   					= None

			if labels is not None:
					if self.config.problem_type is None:
							if self.num_labels == 1:
									lowerCAmelCase__       :      Dict   					= '''regression'''
							elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
									lowerCAmelCase__       :      Dict   					= '''single_label_classification'''
							else:
									lowerCAmelCase__       :      Any   					= '''multi_label_classification'''
					if self.config.problem_type == "regression":
							lowerCAmelCase__       :      List[Any]   					= MSELoss()
							if self.num_labels == 1:
									lowerCAmelCase__       :      Optional[int]   					= loss_fct(logits.squeeze()		, labels.squeeze()		)
							else:
									lowerCAmelCase__       :      List[Any]   					= loss_fct(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		)
					elif self.config.problem_type == "single_label_classification":
							lowerCAmelCase__       :      List[str]   					= CrossEntropyLoss()
							lowerCAmelCase__       :      Optional[int]   					= loss_fct(logits.view(-1		, self.num_labels		)		, labels.view(-1		)		)
					elif self.config.problem_type == "multi_label_classification":
							lowerCAmelCase__       :      int   					= BCEWithLogitsLoss()
							lowerCAmelCase__       :      List[Any]   					= loss_fct(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		)

			if not return_dict:
					lowerCAmelCase__       :      Any   					= (logits,) + outputs[2:]
					return (loss,) + output if loss is not None else output

			return ImageClassifierOutputWithNoAttention(loss=_SCREAMING_SNAKE_CASE		, logits=_SCREAMING_SNAKE_CASE		, hidden_states=outputs.hidden_states		)








from collections import OrderedDict

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


lowerCamelCase						=		logging.get_logger(__name__)


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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





class  _a							(    _BaseAutoModelClass):
	_a  :  List[str]				   =							FLAX_MODEL_MAPPING
lowerCamelCase						=		auto_class_update(FlaxAutoModel)





class  _a							(    _BaseAutoModelClass):
	_a  :  Union[str, Any]				   =							FLAX_MODEL_FOR_PRETRAINING_MAPPING
lowerCamelCase						=		auto_class_update(FlaxAutoModelForPreTraining, head_doc='''pretraining''')





class  _a							(    _BaseAutoModelClass):
	_a  :  Optional[Any]				   =							FLAX_MODEL_FOR_CAUSAL_LM_MAPPING
lowerCamelCase						=		auto_class_update(FlaxAutoModelForCausalLM, head_doc='''causal language modeling''')





class  _a							(    _BaseAutoModelClass):
	_a  :  Tuple				   =							FLAX_MODEL_FOR_MASKED_LM_MAPPING
lowerCamelCase						=		auto_class_update(FlaxAutoModelForMaskedLM, head_doc='''masked language modeling''')





class  _a							(    _BaseAutoModelClass):
	_a  :  Dict				   =							FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
lowerCamelCase						=		auto_class_update(
    FlaxAutoModelForSeqaSeqLM, head_doc='''sequence-to-sequence language modeling''', checkpoint_for_example='''t5-base'''
)





class  _a							(    _BaseAutoModelClass):
	_a  :  Union[str, Any]				   =							FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
lowerCamelCase						=		auto_class_update(
    FlaxAutoModelForSequenceClassification, head_doc='''sequence classification'''
)





class  _a							(    _BaseAutoModelClass):
	_a  :  str				   =							FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING
lowerCamelCase						=		auto_class_update(FlaxAutoModelForQuestionAnswering, head_doc='''question answering''')





class  _a							(    _BaseAutoModelClass):
	_a  :  Union[str, Any]				   =							FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
lowerCamelCase						=		auto_class_update(
    FlaxAutoModelForTokenClassification, head_doc='''token classification'''
)





class  _a							(    _BaseAutoModelClass):
	_a  :  List[Any]				   =							FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING
lowerCamelCase						=		auto_class_update(FlaxAutoModelForMultipleChoice, head_doc='''multiple choice''')





class  _a							(    _BaseAutoModelClass):
	_a  :  Any				   =							FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING
lowerCamelCase						=		auto_class_update(
    FlaxAutoModelForNextSentencePrediction, head_doc='''next sentence prediction'''
)





class  _a							(    _BaseAutoModelClass):
	_a  :  List[Any]				   =							FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
lowerCamelCase						=		auto_class_update(
    FlaxAutoModelForImageClassification, head_doc='''image classification'''
)





class  _a							(    _BaseAutoModelClass):
	_a  :  List[Any]				   =							FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING
lowerCamelCase						=		auto_class_update(FlaxAutoModelForVisionaSeq, head_doc='''vision-to-text modeling''')





class  _a							(    _BaseAutoModelClass):
	_a  :  Optional[Any]				   =							FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING
lowerCamelCase						=		auto_class_update(
    FlaxAutoModelForSpeechSeqaSeq, head_doc='''sequence-to-sequence speech-to-text modeling'''
)




