





import copy

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


_UpperCamelCase       :				List[str]           =			logging.get_logger(__name__)

_UpperCamelCase       :				str           =			{
    """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 		_lowerCAmelCase(		__A):

  """simple docstring"""







  lowerCamelCase__     	=       '''musicgen_decoder'''
  lowerCamelCase__     	=       ['''past_key_values''']

  def __init__(   self    ,							UpperCAmelCase=20_48    ,							UpperCAmelCase=20_48    ,							UpperCAmelCase=24    ,							UpperCAmelCase=40_96    ,							UpperCAmelCase=16    ,							UpperCAmelCase=0.0    ,							UpperCAmelCase=True    ,							UpperCAmelCase="gelu"    ,							UpperCAmelCase=10_24    ,							UpperCAmelCase=0.1    ,							UpperCAmelCase=0.0    ,							UpperCAmelCase=0.0    ,							UpperCAmelCase=0.02    ,							UpperCAmelCase=False    ,							UpperCAmelCase=4    ,							UpperCAmelCase=20_48    ,							UpperCAmelCase=20_48    ,							UpperCAmelCase=None    ,							UpperCAmelCase=False    ,							**UpperCAmelCase    ,							)->   Tuple:
     __A    =  vocab_size
     __A    =  max_position_embeddings
     __A    =  hidden_size
     __A    =  ffn_dim
     __A    =  num_hidden_layers
     __A    =  num_attention_heads
     __A    =  dropout
     __A    =  attention_dropout
     __A    =  activation_dropout
     __A    =  activation_function
     __A    =  initializer_factor
     __A    =  layerdrop
     __A    =  use_cache
     __A    =  scale_embedding  # scale factor will be sqrt(d_model) if True
     __A    =  num_codebooks
     super().__init__(
         pad_token_id=_lowercase    ,							bos_token_id=_lowercase    ,							eos_token_id=_lowercase    ,							tie_word_embeddings=_lowercase    ,							**_lowercase    ,							)







class 		_lowerCAmelCase(		__A):

  """simple docstring"""







  lowerCamelCase__     	=       '''musicgen'''
  lowerCamelCase__     	=       True

  def __init__(   self    ,							**UpperCAmelCase      )->   Optional[int]:
     super().__init__(**_lowercase      )
     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'''      )

     __A    =  kwargs.pop('''text_encoder'''      )
     __A    =  text_encoder_config.pop('''model_type'''      )

     __A    =  kwargs.pop('''audio_encoder'''      )
     __A    =  audio_encoder_config.pop('''model_type'''      )

     __A    =  kwargs.pop('''decoder'''      )

     __A    =  AutoConfig.for_model(_lowercase    ,							**_lowercase      )
     __A    =  AutoConfig.for_model(_lowercase    ,							**_lowercase      )
     __A    =  MusicgenDecoderConfig(**_lowercase      )
     __A    =  True

  @classmethod
  def 						SCREAMING_SNAKE_CASE__			(   cls    ,							UpperCAmelCase    ,							UpperCAmelCase    ,							UpperCAmelCase    ,							**UpperCAmelCase    ,							)->   List[str]:
     return cls(
         text_encoder=text_encoder_config.to_dict()    ,							audio_encoder=audio_encoder_config.to_dict()    ,							decoder=decoder_config.to_dict()    ,							**_lowercase    ,							)





  def 						SCREAMING_SNAKE_CASE__			(   self      )->   Any:
     __A    =  copy.deepcopy(self.__dict__      )
     __A    =  self.text_encoder.to_dict()
     __A    =  self.audio_encoder.to_dict()
     __A    =  self.decoder.to_dict()
     __A    =  self.__class__.model_type
     return output








from collections import OrderedDict
from typing import Mapping

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


UpperCAmelCase_       : Union[str, Any]							=    logging.get_logger(__name__)

UpperCAmelCase_       : int							=    {
    """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   lowercase__     (				__A	):
  __UpperCamelCase						  =	"""electra"""







  def __init__(						self     ,    _lowercase=30_522     ,    _lowercase=128     ,    _lowercase=256     ,    _lowercase=12     ,    _lowercase=4     ,    _lowercase=1_024     ,    _lowercase="gelu"     ,    _lowercase=0.1     ,    _lowercase=0.1     ,    _lowercase=512     ,    _lowercase=2     ,    _lowercase=0.02     ,    _lowercase=1e-12     ,    _lowercase="first"     ,    _lowercase=True     ,    _lowercase="gelu"     ,    _lowercase=0.1     ,    _lowercase=0     ,    _lowercase="absolute"     ,    _lowercase=True     ,    _lowercase=None     ,    **_lowercase     ,    ):
       super().__init__(pad_token_id=_lowercase     ,    **_lowercase    )

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

       lowerCAmelCase_       :							str			 =		summary_type
       lowerCAmelCase_       :							Optional[int]			 =		summary_use_proj
       lowerCAmelCase_       :							Optional[int]			 =		summary_activation
       lowerCAmelCase_       :							int			 =		summary_last_dropout
       lowerCAmelCase_       :							str			 =		position_embedding_type
       lowerCAmelCase_       :							Optional[int]			 =		use_cache
       lowerCAmelCase_       :							Tuple			 =		classifier_dropout





class   lowercase__     (				__A	):







  @property
  def 						UpperCAmelCase__		(						self    ):
       if self.task == "multiple-choice":
            lowerCAmelCase_       :							Optional[int]			 =		{0: """batch""", 1: """choice""", 2: """sequence"""}
       else:
            lowerCAmelCase_       :							Any			 =		{0: """batch""", 1: """sequence"""}
       return OrderedDict(
           [
               ("""input_ids""", dynamic_axis),
               ("""attention_mask""", dynamic_axis),
               ("""token_type_ids""", dynamic_axis),
           ]    )
