




import copy

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


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

SCREAMING_SNAKE_CASE__	:				Optional[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 		UpperCamelCase__     (_UpperCAmelCase					):

    '''simple docstring'''



    lowerCamelCase_				:     int     					=				'''musicgen_decoder'''
    lowerCamelCase_				:     Optional[int]     					=				['''past_key_values''']







    def __init__(   self					,  UpperCamelCase__=2048					,  UpperCamelCase__=2048					,  UpperCamelCase__=24					,  UpperCamelCase__=4096					,  UpperCamelCase__=16					,  UpperCamelCase__=0.0					,  UpperCamelCase__=True					,  UpperCamelCase__="gelu"					,  UpperCamelCase__=1024					,  UpperCamelCase__=0.1					,  UpperCamelCase__=0.0					,  UpperCamelCase__=0.0					,  UpperCamelCase__=0.02					,  UpperCamelCase__=False					,  UpperCamelCase__=4					,  UpperCamelCase__=2048					,  UpperCamelCase__=2048					,  UpperCamelCase__=None					,  UpperCamelCase__=False					,  **UpperCamelCase__					,  )					->				List[str]:
           lowerCamelCase       :				Tuple      			= vocab_size
           lowerCamelCase       :				Dict      			= max_position_embeddings
           lowerCamelCase       :				str      			= hidden_size
           lowerCamelCase       :				Dict      			= ffn_dim
           lowerCamelCase       :				Optional[Any]      			= num_hidden_layers
           lowerCamelCase       :				Tuple      			= num_attention_heads
           lowerCamelCase       :				Optional[int]      			= dropout
           lowerCamelCase       :				Tuple      			= attention_dropout
           lowerCamelCase       :				List[str]      			= activation_dropout
           lowerCamelCase       :				List[Any]      			= activation_function
           lowerCamelCase       :				Tuple      			= initializer_factor
           lowerCamelCase       :				Any      			= layerdrop
           lowerCamelCase       :				str      			= use_cache
           lowerCamelCase       :				Dict      			= scale_embedding  # scale factor will be sqrt(d_model) if True
           lowerCamelCase       :				Any      			= num_codebooks
           super().__init__(
               pad_token_id=lowerCAmelCase__					,  bos_token_id=lowerCAmelCase__					,  eos_token_id=lowerCAmelCase__					,  tie_word_embeddings=lowerCAmelCase__					,  **lowerCAmelCase__					,  )




class 		UpperCamelCase__     (_UpperCAmelCase					):

    '''simple docstring'''



    lowerCamelCase_				:     Optional[int]     					=				'''musicgen'''
    lowerCamelCase_				:     Any     					=				True







    def __init__(   self					,  **UpperCamelCase__					)					->				Union[str, Any]:
           super().__init__(**lowerCAmelCase__					)
           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"					)

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

           lowerCamelCase       :				int      			= kwargs.pop("audio_encoder"					)
           lowerCamelCase       :				Optional[Any]      			= audio_encoder_config.pop("model_type"					)

           lowerCamelCase       :				List[str]      			= kwargs.pop("decoder"					)

           lowerCamelCase       :				Tuple      			= AutoConfig.for_model(lowerCAmelCase__					,  **lowerCAmelCase__					)
           lowerCamelCase       :				List[Any]      			= AutoConfig.for_model(lowerCAmelCase__					,  **lowerCAmelCase__					)
           lowerCamelCase       :				Optional[Any]      			= MusicgenDecoderConfig(**lowerCAmelCase__					)
           lowerCamelCase       :				int      			= True







    @classmethod
    def    _lowercase					(   cls					,  UpperCamelCase__					,  UpperCamelCase__					,  UpperCamelCase__					,  **UpperCamelCase__					,  )					->				Tuple:
           return cls(
               text_encoder=text_encoder_config.to_dict()					,  audio_encoder=audio_encoder_config.to_dict()					,  decoder=decoder_config.to_dict()					,  **lowerCAmelCase__					,  )







    def    _lowercase					(   self					)					->				Tuple:
           lowerCamelCase       :				int      			= copy.deepcopy(self.__dict__					)
           lowerCamelCase       :				Tuple      			= self.text_encoder.to_dict()
           lowerCamelCase       :				Optional[Any]      			= self.audio_encoder.to_dict()
           lowerCamelCase       :				Dict      			= self.decoder.to_dict()
           lowerCamelCase       :				List[str]      			= self.__class__.model_type
           return output












import copy

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


SCREAMING_SNAKE_CASE__	:				int  =       logging.get_logger(__name__)




class 		UpperCamelCase__     (lowerCAmelCase__					):

    '''simple docstring'''



    lowerCamelCase_				:     str     					=				"""speech-encoder-decoder"""
    lowerCamelCase_				:     List[str]     					=				True







    def __init__(   self					,  **UpperCamelCase__					)					->				Dict:
           super().__init__(**UpperCamelCase__					)
           if "encoder" not in kwargs or "decoder" not in kwargs:
                  raise ValueError(
                      F'''A configuraton of type {self.model_type} cannot be instantiated because not both `encoder` and'''
                      F''' `decoder` sub-configurations are passed, but only {kwargs}'''					)

           lowerCamelCase       :				Dict      			= kwargs.pop("encoder"					)
           lowerCamelCase       :				Tuple      			= encoder_config.pop("model_type"					)
           lowerCamelCase       :				int      			= kwargs.pop("decoder"					)
           lowerCamelCase       :				List[Any]      			= decoder_config.pop("model_type"					)

           lowerCamelCase       :				str      			= AutoConfig.for_model(UpperCamelCase__					,  **UpperCamelCase__					)
           lowerCamelCase       :				str      			= AutoConfig.for_model(UpperCamelCase__					,  **UpperCamelCase__					)
           lowerCamelCase       :				Tuple      			= True







    @classmethod
    def    _lowercase					(   cls					,  UpperCamelCase__					,  UpperCamelCase__					,  **UpperCamelCase__					)					->				PretrainedConfig:
           logger.info("Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"					)
           lowerCamelCase       :				Dict      			= True
           lowerCamelCase       :				Union[str, Any]      			= True

           return cls(encoder=encoder_config.to_dict()					,  decoder=decoder_config.to_dict()					,  **UpperCamelCase__					)







    def    _lowercase					(   self					)					->				Tuple:
           lowerCamelCase       :				Tuple      			= copy.deepcopy(self.__dict__					)
           lowerCamelCase       :				Optional[int]      			= self.encoder.to_dict()
           lowerCamelCase       :				List[str]      			= self.decoder.to_dict()
           lowerCamelCase       :				Dict      			= self.__class__.model_type
           return output






