



import copy

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


UpperCAmelCase__			:   Dict      			=    logging.get_logger(__name__)

UpperCAmelCase__			:   Any      			=    {
    '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_		(		lowercase_     ):
		SCREAMING_SNAKE_CASE_       :			Optional[Any]					       =	"""musicgen_decoder"""
		SCREAMING_SNAKE_CASE_       :			Union[str, Any]					       =	["""past_key_values"""]







		def __init__(    self  :   str       ,		UpperCAmelCase_  :   Union[str, Any]=2048       ,		UpperCAmelCase_  :   Dict=2048       ,		UpperCAmelCase_  :   List[str]=24       ,		UpperCAmelCase_  :   int=4096       ,		UpperCAmelCase_  :   Optional[Any]=16       ,		UpperCAmelCase_  :   List[Any]=0.0       ,		UpperCAmelCase_  :   int=True       ,		UpperCAmelCase_  :   Optional[Any]="gelu"       ,		UpperCAmelCase_  :   Any=1024       ,		UpperCAmelCase_  :   str=0.1       ,		UpperCAmelCase_  :   Optional[int]=0.0       ,		UpperCAmelCase_  :   Optional[Any]=0.0       ,		UpperCAmelCase_  :   Dict=0.02       ,		UpperCAmelCase_  :   List[Any]=False       ,		UpperCAmelCase_  :   int=4       ,		UpperCAmelCase_  :   int=2048       ,		UpperCAmelCase_  :   Union[str, Any]=2048       ,		UpperCAmelCase_  :   Tuple=None       ,		UpperCAmelCase_  :   Optional[Any]=False       ,		**UpperCAmelCase_  :   Any       ,		)       ->		int:


						'''simple docstring'''







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





class 							lowerCAmelCase_		(		lowercase_     ):
		SCREAMING_SNAKE_CASE_       :			str					       =	"""musicgen"""
		SCREAMING_SNAKE_CASE_       :			List[Any]					       =	True







		def __init__(    self  :   List[Any]       ,		**UpperCAmelCase_  :   Union[str, Any]					)       ->		List[Any]:


						'''simple docstring'''







						super().__init__(**UpperCAmelCase_					)
						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'''					)

						_UpperCAmelCase						:  Optional[int]     					=	kwargs.pop('''text_encoder'''					)
						_UpperCAmelCase						:  str     					=	text_encoder_config.pop('''model_type'''					)

						_UpperCAmelCase						:  List[str]     					=	kwargs.pop('''audio_encoder'''					)
						_UpperCAmelCase						:  Dict     					=	audio_encoder_config.pop('''model_type'''					)

						_UpperCAmelCase						:  Any     					=	kwargs.pop('''decoder'''					)

						_UpperCAmelCase						:  str     					=	AutoConfig.for_model(UpperCAmelCase_       ,		**UpperCAmelCase_					)
						_UpperCAmelCase						:  Dict     					=	AutoConfig.for_model(UpperCAmelCase_       ,		**UpperCAmelCase_					)
						_UpperCAmelCase						:  List[Any]     					=	MusicgenDecoderConfig(**UpperCAmelCase_					)
						_UpperCAmelCase						:  Union[str, Any]     					=	True







		@classmethod
		def 					a_  (    cls  :   Optional[Any]       ,		UpperCAmelCase_  :   PretrainedConfig       ,		UpperCAmelCase_  :   PretrainedConfig       ,		UpperCAmelCase_  :   MusicgenDecoderConfig       ,		**UpperCAmelCase_  :   Tuple       ,		)       ->		Dict:


						'''simple docstring'''







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







		def 					a_  (    self  :   Union[str, Any]					)       ->		List[Any]:


						'''simple docstring'''







						_UpperCAmelCase						:  Tuple     					=	copy.deepcopy(self.__dict__					)
						_UpperCAmelCase						:  Union[str, Any]     					=	self.text_encoder.to_dict()
						_UpperCAmelCase						:  Union[str, Any]     					=	self.audio_encoder.to_dict()
						_UpperCAmelCase						:  str     					=	self.decoder.to_dict()
						_UpperCAmelCase						:  Tuple     					=	self.__class__.model_type
						return output





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available


UpperCAmelCase__			:   Optional[Any]      			=    {}

try:
					if not is_sentencepiece_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase__			:   List[Any]      			=    ['MBart50Tokenizer']

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase__			:   int      			=    ['MBart50TokenizerFast']


if TYPE_CHECKING:
					try:
										if not is_sentencepiece_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_mbartaa import MBartaaTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_mbartaa_fast import MBartaaTokenizerFast

else:
					import sys

					UpperCAmelCase__			:   str      			=    _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
