

import copy

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


UpperCAmelCase__	:       int			      =      logging.get_logger(__name__)

UpperCAmelCase__	:       List[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     a__    (				snake_case__    ):







		"""simple docstring"""




		UpperCAmelCase__ :	Dict         ='''musicgen_decoder'''
		UpperCAmelCase__ :	Any         =['''past_key_values''']


		def __init__(     self      :	Tuple			,			UpperCAmelCase__      :	Dict=2_0_4_8			,			UpperCAmelCase__      :	str=2_0_4_8			,			UpperCAmelCase__      :	Optional[int]=2_4			,			UpperCAmelCase__      :	Union[str, Any]=4_0_9_6			,			UpperCAmelCase__      :	str=1_6			,			UpperCAmelCase__      :	Optional[Any]=0.0			,			UpperCAmelCase__      :	Tuple=True			,			UpperCAmelCase__      :	int="gelu"			,			UpperCAmelCase__      :	Any=1_0_2_4			,			UpperCAmelCase__      :	Tuple=0.1			,			UpperCAmelCase__      :	Dict=0.0			,			UpperCAmelCase__      :	List[str]=0.0			,			UpperCAmelCase__      :	List[Any]=0.02			,			UpperCAmelCase__      :	Optional[Any]=False			,			UpperCAmelCase__      :	str=4			,			UpperCAmelCase__      :	Tuple=2_0_4_8			,			UpperCAmelCase__      :	Tuple=2_0_4_8			,			UpperCAmelCase__      :	List[Any]=None			,			UpperCAmelCase__      :	int=False			,			**UpperCAmelCase__      :	Dict			,			)   ->Union[str, Any]:
								"""simple docstring"""







								SCREAMING_SNAKE_CASE	: Optional[int]					       =				vocab_size
								SCREAMING_SNAKE_CASE	: str					       =				max_position_embeddings
								SCREAMING_SNAKE_CASE	: Any					       =				hidden_size
								SCREAMING_SNAKE_CASE	: Optional[int]					       =				ffn_dim
								SCREAMING_SNAKE_CASE	: str					       =				num_hidden_layers
								SCREAMING_SNAKE_CASE	: Optional[int]					       =				num_attention_heads
								SCREAMING_SNAKE_CASE	: List[str]					       =				dropout
								SCREAMING_SNAKE_CASE	: str					       =				attention_dropout
								SCREAMING_SNAKE_CASE	: Any					       =				activation_dropout
								SCREAMING_SNAKE_CASE	: Optional[int]					       =				activation_function
								SCREAMING_SNAKE_CASE	: Dict					       =				initializer_factor
								SCREAMING_SNAKE_CASE	: int					       =				layerdrop
								SCREAMING_SNAKE_CASE	: Tuple					       =				use_cache
								SCREAMING_SNAKE_CASE	: List[Any]					       =				scale_embedding  # scale factor will be sqrt(d_model) if True
								SCREAMING_SNAKE_CASE	: Optional[int]					       =				num_codebooks
								super().__init__(
								    pad_token_id=_A			,			bos_token_id=_A			,			eos_token_id=_A			,			tie_word_embeddings=_A			,			**_A			,			)







class     a__    (				snake_case__    ):







		"""simple docstring"""




		UpperCAmelCase__ :	List[str]         ='''musicgen'''
		UpperCAmelCase__ :	Optional[Any]         =True


		def __init__(     self      :	List[str]			,			**UpperCAmelCase__      :	Dict						)   ->List[Any]:
								"""simple docstring"""







								super().__init__(**_A						)
								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"""						)

								SCREAMING_SNAKE_CASE	: Optional[int]					       =				kwargs.pop("""text_encoder"""						)
								SCREAMING_SNAKE_CASE	: int					       =				text_encoder_config.pop("""model_type"""						)

								SCREAMING_SNAKE_CASE	: Tuple					       =				kwargs.pop("""audio_encoder"""						)
								SCREAMING_SNAKE_CASE	: Dict					       =				audio_encoder_config.pop("""model_type"""						)

								SCREAMING_SNAKE_CASE	: Any					       =				kwargs.pop("""decoder"""						)

								SCREAMING_SNAKE_CASE	: List[Any]					       =				AutoConfig.for_model(_A			,			**_A						)
								SCREAMING_SNAKE_CASE	: List[str]					       =				AutoConfig.for_model(_A			,			**_A						)
								SCREAMING_SNAKE_CASE	: List[Any]					       =				MusicgenDecoderConfig(**_A						)
								SCREAMING_SNAKE_CASE	: Any					       =				True


		@classmethod
		def 	_lowercase (     cls      :	Optional[Any]			,			UpperCAmelCase__      :	str			,			UpperCAmelCase__      :	List[str]			,			UpperCAmelCase__      :	int			,			**UpperCAmelCase__      :	Dict			,			)   ->Optional[int]:
								"""simple docstring"""







								return cls(
								    text_encoder=text_encoder_config.to_dict()			,			audio_encoder=audio_encoder_config.to_dict()			,			decoder=decoder_config.to_dict()			,			**_A			,			)




		def 	_lowercase (     self      :	str						)   ->Tuple:
								"""simple docstring"""







								SCREAMING_SNAKE_CASE	: int					       =				copy.deepcopy(self.__dict__						)
								SCREAMING_SNAKE_CASE	: List[Any]					       =				self.text_encoder.to_dict()
								SCREAMING_SNAKE_CASE	: Any					       =				self.audio_encoder.to_dict()
								SCREAMING_SNAKE_CASE	: int					       =				self.decoder.to_dict()
								SCREAMING_SNAKE_CASE	: Optional[int]					       =				self.__class__.model_type
								return output







UpperCAmelCase__	:       Union[str, Any]			      =      """
# Installation de Transformers
! pip install transformers datasets
# Pour installer à partir du code source au lieu de la dernière version, commentez la commande ci-dessus et décommentez la suivante.
# ! pip install git+https://github.com/huggingface/transformers.git
"""

UpperCAmelCase__	:       List[Any]			      =      [{"""type""": """code""", """content""": INSTALL_CONTENT}]
UpperCAmelCase__	:       List[Any]			      =      {
    """{processor_class}""": """FakeProcessorClass""",
    """{model_class}""": """FakeModelClass""",
    """{object_class}""": """FakeObjectClass""",
}




