



'''simple docstring'''
import copy

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


_UpperCamelCase									=      logging.get_logger(__name__)

_UpperCamelCase									=      {
    '''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	(     __SCREAMING_SNAKE_CASE     ):
		_SCREAMING_SNAKE_CASE       :     int       =      "musicgen_decoder"
		_SCREAMING_SNAKE_CASE       :     str       =      ["past_key_values"]





		def __init__(  self			,							__UpperCAmelCase=2_048			,							__UpperCAmelCase=2_048			,							__UpperCAmelCase=24			,							__UpperCAmelCase=4_096			,							__UpperCAmelCase=16			,							__UpperCAmelCase=0.0			,							__UpperCAmelCase=True			,							__UpperCAmelCase="gelu"			,							__UpperCAmelCase=1_024			,							__UpperCAmelCase=0.1			,							__UpperCAmelCase=0.0			,							__UpperCAmelCase=0.0			,							__UpperCAmelCase=0.02			,							__UpperCAmelCase=False			,							__UpperCAmelCase=4			,							__UpperCAmelCase=2_048			,							__UpperCAmelCase=2_048			,							__UpperCAmelCase=None			,							__UpperCAmelCase=False			,							**__UpperCAmelCase			,							)							->  int:

					'''simple docstring'''
					__UpperCAmelCase :   Dict    					=  vocab_size
					__UpperCAmelCase :   Optional[int]    					=  max_position_embeddings
					__UpperCAmelCase :   List[Any]    					=  hidden_size
					__UpperCAmelCase :   Optional[Any]    					=  ffn_dim
					__UpperCAmelCase :   str    					=  num_hidden_layers
					__UpperCAmelCase :   Optional[Any]    					=  num_attention_heads
					__UpperCAmelCase :   Optional[int]    					=  dropout
					__UpperCAmelCase :   Optional[int]    					=  attention_dropout
					__UpperCAmelCase :   Optional[Any]    					=  activation_dropout
					__UpperCAmelCase :   List[Any]    					=  activation_function
					__UpperCAmelCase :   List[Any]    					=  initializer_factor
					__UpperCAmelCase :   Dict    					=  layerdrop
					__UpperCAmelCase :   Union[str, Any]    					=  use_cache
					__UpperCAmelCase :   List[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 _A	(     __SCREAMING_SNAKE_CASE     ):
		_SCREAMING_SNAKE_CASE       :     List[str]       =      "musicgen"
		_SCREAMING_SNAKE_CASE       :     Optional[Any]       =      True





		def __init__(  self			,							**__UpperCAmelCase					)							->  str:

					'''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 :   Tuple    					=  kwargs.pop("""text_encoder"""					)
					__UpperCAmelCase :   int    					=  text_encoder_config.pop("""model_type"""					)

					__UpperCAmelCase :   int    					=  kwargs.pop("""audio_encoder"""					)
					__UpperCAmelCase :   int    					=  audio_encoder_config.pop("""model_type"""					)

					__UpperCAmelCase :   Union[str, Any]    					=  kwargs.pop("""decoder"""					)

					__UpperCAmelCase :   Union[str, Any]    					=  AutoConfig.for_model(__UpperCAmelCase			,							**__UpperCAmelCase					)
					__UpperCAmelCase :   Any    					=  AutoConfig.for_model(__UpperCAmelCase			,							**__UpperCAmelCase					)
					__UpperCAmelCase :   Optional[int]    					=  MusicgenDecoderConfig(**__UpperCAmelCase					)
					__UpperCAmelCase :   Dict    					=  True





		@classmethod
		def 				__A							(  cls			,							__UpperCAmelCase			,							__UpperCAmelCase			,							__UpperCAmelCase			,							**__UpperCAmelCase			,							)							->  Tuple:

					'''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					)							->  Dict:

					'''simple docstring'''
					__UpperCAmelCase :   Union[str, Any]    					=  copy.deepcopy(self.__dict__					)
					__UpperCAmelCase :   Optional[int]    					=  self.text_encoder.to_dict()
					__UpperCAmelCase :   List[str]    					=  self.audio_encoder.to_dict()
					__UpperCAmelCase :   Optional[int]    					=  self.decoder.to_dict()
					__UpperCAmelCase :   Dict    					=  self.__class__.model_type
					return output









'''simple docstring'''
from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_UpperCamelCase									=      {'''configuration_t5''': ['''T5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''T5Config''', '''T5OnnxConfig''']}

try:
					if not is_sentencepiece_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_UpperCamelCase									=      ['''T5Tokenizer''']

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_UpperCamelCase									=      ['''T5TokenizerFast''']

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_UpperCamelCase									=      [
					    '''T5_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''T5EncoderModel''',
					    '''T5ForConditionalGeneration''',
					    '''T5Model''',
					    '''T5PreTrainedModel''',
					    '''load_tf_weights_in_t5''',
					    '''T5ForQuestionAnswering''',
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_UpperCamelCase									=      [
					    '''TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''TFT5EncoderModel''',
					    '''TFT5ForConditionalGeneration''',
					    '''TFT5Model''',
					    '''TFT5PreTrainedModel''',
					]

try:
					if not is_flax_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_UpperCamelCase									=      [
					    '''FlaxT5EncoderModel''',
					    '''FlaxT5ForConditionalGeneration''',
					    '''FlaxT5Model''',
					    '''FlaxT5PreTrainedModel''',
					]


if TYPE_CHECKING:
					from .configuration_ta import T5_PRETRAINED_CONFIG_ARCHIVE_MAP, TaConfig, TaOnnxConfig

					try:
										if not is_sentencepiece_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_ta import TaTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_ta_fast import TaTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_ta import (
										    T5_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TaEncoderModel,
										    TaForConditionalGeneration,
										    TaForQuestionAnswering,
										    TaModel,
										    TaPreTrainedModel,
										    load_tf_weights_in_ta,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_ta import (
										    TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFTaEncoderModel,
										    TFTaForConditionalGeneration,
										    TFTaModel,
										    TFTaPreTrainedModel,
										)

					try:
										if not is_flax_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_flax_ta import (
										    FlaxTaEncoderModel,
										    FlaxTaForConditionalGeneration,
										    FlaxTaModel,
										    FlaxTaPreTrainedModel,
										)


else:
					import sys

					_UpperCamelCase									=      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




