





"""simple docstring"""




from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCamelCase_	 =logging.get_logger(__name__)

UpperCamelCase_	 ={
    """google/electra-small-generator""": """https://huggingface.co/google/electra-small-generator/resolve/main/config.json""",
    """google/electra-base-generator""": """https://huggingface.co/google/electra-base-generator/resolve/main/config.json""",
    """google/electra-large-generator""": """https://huggingface.co/google/electra-large-generator/resolve/main/config.json""",
    """google/electra-small-discriminator""": (
        """https://huggingface.co/google/electra-small-discriminator/resolve/main/config.json"""
    ),
    """google/electra-base-discriminator""": (
        """https://huggingface.co/google/electra-base-discriminator/resolve/main/config.json"""
    ),
    """google/electra-large-discriminator""": (
        """https://huggingface.co/google/electra-large-discriminator/resolve/main/config.json"""
    ),
}




class 					_a		( snake_case_							):
				UpperCamelCase								=       '''electra'''






				def __init__(					self						:       Any,					lowerCAmelCase__						:       Tuple=3_0_5_2_2,					lowerCAmelCase__						:       List[str]=1_2_8,					lowerCAmelCase__						:       List[Any]=2_5_6,					lowerCAmelCase__						:       Tuple=1_2,					lowerCAmelCase__						:       Union[str, Any]=4,					lowerCAmelCase__						:       str=1_0_2_4,					lowerCAmelCase__						:       Dict="gelu",					lowerCAmelCase__						:       List[str]=0.1,					lowerCAmelCase__						:       Any=0.1,					lowerCAmelCase__						:       Optional[Any]=5_1_2,					lowerCAmelCase__						:       str=2,					lowerCAmelCase__						:       Union[str, Any]=0.02,					lowerCAmelCase__						:       List[Any]=1e-1_2,					lowerCAmelCase__						:       Optional[Any]="first",					lowerCAmelCase__						:       List[str]=True,					lowerCAmelCase__						:       Optional[int]="gelu",					lowerCAmelCase__						:       List[Any]=0.1,					lowerCAmelCase__						:       Union[str, Any]=0,					lowerCAmelCase__						:       Optional[Any]="absolute",					lowerCAmelCase__						:       List[Any]=True,					lowerCAmelCase__						:       Tuple=None,					**lowerCAmelCase__						:       Dict,					)      -> List[Any]:




										'''simple docstring'''



										super().__init__(pad_token_id=SCREAMING_SNAKE_CASE_,					**SCREAMING_SNAKE_CASE_				)

										_UpperCamelCase     :   List[Any]      =       vocab_size
										_UpperCamelCase     :   str      =       embedding_size
										_UpperCamelCase     :   Any      =       hidden_size
										_UpperCamelCase     :   Dict      =       num_hidden_layers
										_UpperCamelCase     :   Optional[int]      =       num_attention_heads
										_UpperCamelCase     :   Optional[int]      =       intermediate_size
										_UpperCamelCase     :   Any      =       hidden_act
										_UpperCamelCase     :   Union[str, Any]      =       hidden_dropout_prob
										_UpperCamelCase     :   Dict      =       attention_probs_dropout_prob
										_UpperCamelCase     :   List[str]      =       max_position_embeddings
										_UpperCamelCase     :   Dict      =       type_vocab_size
										_UpperCamelCase     :   Optional[Any]      =       initializer_range
										_UpperCamelCase     :   Optional[Any]      =       layer_norm_eps

										_UpperCamelCase     :   Optional[Any]      =       summary_type
										_UpperCamelCase     :   Dict      =       summary_use_proj
										_UpperCamelCase     :   Dict      =       summary_activation
										_UpperCamelCase     :   int      =       summary_last_dropout
										_UpperCamelCase     :   Any      =       position_embedding_type
										_UpperCamelCase     :   Dict      =       use_cache
										_UpperCamelCase     :   str      =       classifier_dropout




class 					_a		( snake_case_							):






				@property
				def 							snake_case      (					self						:       List[str]				)      -> List[str]:




										'''simple docstring'''



										if self.task == "multiple-choice":
																_UpperCamelCase     :   str      =       {0: '''batch''', 1: '''choice''', 2: '''sequence'''}
										else:
																_UpperCamelCase     :   Optional[Any]      =       {0: '''batch''', 1: '''sequence'''}
										return OrderedDict(
										    [
										        ('''input_ids''', dynamic_axis),
										        ('''attention_mask''', dynamic_axis),
										        ('''token_type_ids''', dynamic_axis),
										    ]				)









"""simple docstring"""





import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


_lowercase						   =     logging.get_logger(__name__)

_lowercase						   =     {
    """facebook/musicgen-small""": """https://huggingface.co/facebook/musicgen-small/resolve/main/config.json""",
    # See all Musicgen models at https://huggingface.co/models?filter=musicgen
}

class    __lowercase							(      snake_case_						):


				'''simple docstring'''


				_lowerCAmelCase						      ="musicgen_decoder"
				_lowerCAmelCase						      =["past_key_values"]

				def __init__( self :  List[str]   ,SCREAMING_SNAKE_CASE_ :  Dict=2_0_4_8   ,SCREAMING_SNAKE_CASE_ :  str=2_0_4_8   ,SCREAMING_SNAKE_CASE_ :  List[str]=2_4   ,SCREAMING_SNAKE_CASE_ :  int=4_0_9_6   ,SCREAMING_SNAKE_CASE_ :  List[Any]=1_6   ,SCREAMING_SNAKE_CASE_ :  Dict=0.0   ,SCREAMING_SNAKE_CASE_ :  Any=True   ,SCREAMING_SNAKE_CASE_ :  Any="gelu"   ,SCREAMING_SNAKE_CASE_ :  Tuple=1_0_2_4   ,SCREAMING_SNAKE_CASE_ :  Any=0.1   ,SCREAMING_SNAKE_CASE_ :  List[str]=0.0   ,SCREAMING_SNAKE_CASE_ :  Optional[Any]=0.0   ,SCREAMING_SNAKE_CASE_ :  Tuple=0.02   ,SCREAMING_SNAKE_CASE_ :  Optional[Any]=False   ,SCREAMING_SNAKE_CASE_ :  List[str]=4   ,SCREAMING_SNAKE_CASE_ :  str=2_0_4_8   ,SCREAMING_SNAKE_CASE_ :  str=2_0_4_8   ,SCREAMING_SNAKE_CASE_ :  Optional[int]=None   ,SCREAMING_SNAKE_CASE_ :  Tuple=False   ,**SCREAMING_SNAKE_CASE_ :  Union[str, Any]   ,):
										snake_case__							:       List[str]				      =       vocab_size
										snake_case__							:       List[str]				      =       max_position_embeddings
										snake_case__							:       List[Any]				      =       hidden_size
										snake_case__							:       Dict				      =       ffn_dim
										snake_case__							:       Union[str, Any]				      =       num_hidden_layers
										snake_case__							:       List[str]				      =       num_attention_heads
										snake_case__							:       Optional[Any]				      =       dropout
										snake_case__							:       Dict				      =       attention_dropout
										snake_case__							:       Union[str, Any]				      =       activation_dropout
										snake_case__							:       Dict				      =       activation_function
										snake_case__							:       Union[str, Any]				      =       initializer_factor
										snake_case__							:       List[str]				      =       layerdrop
										snake_case__							:       Any				      =       use_cache
										snake_case__							:       Tuple				      =       scale_embedding  # scale factor will be sqrt(d_model) if True
										snake_case__							:       Any				      =       num_codebooks
										super().__init__(
										    pad_token_id=SCREAMING_SNAKE_CASE_   ,bos_token_id=SCREAMING_SNAKE_CASE_   ,eos_token_id=SCREAMING_SNAKE_CASE_   ,tie_word_embeddings=SCREAMING_SNAKE_CASE_   ,**SCREAMING_SNAKE_CASE_   ,)







class    __lowercase							(      snake_case_						):


				'''simple docstring'''


				_lowerCAmelCase						      ="musicgen"
				_lowerCAmelCase						      =True

				def __init__( self :  Optional[Any]   ,**SCREAMING_SNAKE_CASE_ :  Dict   ):
										super().__init__(**SCREAMING_SNAKE_CASE_   )
										if "text_encoder" not in kwargs or "audio_encoder" not in kwargs or "decoder" not in kwargs:
																raise ValueError('''Config has to be initialized with text_encoder, audio_encoder and decoder config'''   )

										snake_case__							:       Optional[int]				      =       kwargs.pop('''text_encoder'''   )
										snake_case__							:       Optional[Any]				      =       text_encoder_config.pop('''model_type'''   )

										snake_case__							:       Union[str, Any]				      =       kwargs.pop('''audio_encoder'''   )
										snake_case__							:       Dict				      =       audio_encoder_config.pop('''model_type'''   )

										snake_case__							:       Optional[Any]				      =       kwargs.pop('''decoder'''   )

										snake_case__							:       Union[str, Any]				      =       AutoConfig.for_model(SCREAMING_SNAKE_CASE_   ,**SCREAMING_SNAKE_CASE_   )
										snake_case__							:       List[Any]				      =       AutoConfig.for_model(SCREAMING_SNAKE_CASE_   ,**SCREAMING_SNAKE_CASE_   )
										snake_case__							:       List[str]				      =       MusicgenDecoderConfig(**SCREAMING_SNAKE_CASE_   )
										snake_case__							:       Union[str, Any]				      =       True

				@classmethod
				def    _lowerCamelCase       ( cls :  Dict   ,SCREAMING_SNAKE_CASE_ :  PretrainedConfig   ,SCREAMING_SNAKE_CASE_ :  PretrainedConfig   ,SCREAMING_SNAKE_CASE_ :  MusicgenDecoderConfig   ,**SCREAMING_SNAKE_CASE_ :  str   ,):
										return cls(
										    text_encoder=text_encoder_config.to_dict()   ,audio_encoder=audio_encoder_config.to_dict()   ,decoder=decoder_config.to_dict()   ,**SCREAMING_SNAKE_CASE_   ,)





				def    _lowerCamelCase       ( self :  Optional[Any]   ):
										snake_case__							:       Optional[Any]				      =       copy.deepcopy(self.__dict__   )
										snake_case__							:       Any				      =       self.text_encoder.to_dict()
										snake_case__							:       Dict				      =       self.audio_encoder.to_dict()
										snake_case__							:       Dict				      =       self.decoder.to_dict()
										snake_case__							:       Optional[int]				      =       self.__class__.model_type
										return output


