






UpperCAmelCase__			 =	{
    '''0000''': '''0''',
    '''0001''': '''1''',
    '''0010''': '''2''',
    '''0011''': '''3''',
    '''0100''': '''4''',
    '''0101''': '''5''',
    '''0110''': '''6''',
    '''0111''': '''7''',
    '''1000''': '''8''',
    '''1001''': '''9''',
    '''1010''': '''a''',
    '''1011''': '''b''',
    '''1100''': '''c''',
    '''1101''': '''d''',
    '''1110''': '''e''',
    '''1111''': '''f''',
}







def 						a_      (__A			)							->	str:



					"""simple docstring"""
					__a				:	Tuple			=				str(__A			).strip()

					# Exceptions
					if not binary_str:
										raise ValueError("Empty string was passed to the function"			)
					__a				:	List[Any]			=				binary_str[0] == "-"
					__a				:	Optional[int]			=				binary_str[1:] if is_negative else binary_str
					if not all(char in "01" for char in binary_str			):
										raise ValueError("Non-binary value was passed to the function"			)

					__a				:	str			=				(
					    "0" * (4 * (divmod(len(__A			)							,					4			)[0] + 1) - len(__A			)) + binary_str
					)

					__a				:	Any			=				[]
					for x in range(0							,					len(__A			)							,					4			):
										hexadecimal.append(BITS_TO_HEX[binary_str[x : x + 4]]			)
					__a				:	List[str]			=				"0x" + "".join(__A			)

					return "-" + hexadecimal_str if is_negative else hexadecimal_str


if __name__ == "__main__":
			from doctest import testmod

			testmod()













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        snake_case_					(						__UpperCamelCase			):

						"""simple docstring"""



						snake_case__   					=			"""musicgen_decoder"""
						snake_case__   					=			["""past_key_values"""]



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




											'''simple docstring'''



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




class        snake_case_					(						__UpperCamelCase			):

						"""simple docstring"""



						snake_case__   					=			"""musicgen"""
						snake_case__   					=			True



						def __init__(self:				Union[str, Any]   ,				**__UpperCAmelCase:				Optional[int]      )						->    List[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"      )

											__a				:	List[Any]			=				kwargs.pop("text_encoder"      )
											__a				:	Optional[Any]			=				text_encoder_config.pop("model_type"      )

											__a				:	Union[str, Any]			=				kwargs.pop("audio_encoder"      )
											__a				:	Dict			=				audio_encoder_config.pop("model_type"      )

											__a				:	Optional[Any]			=				kwargs.pop("decoder"      )

											__a				:	Optional[int]			=				AutoConfig.for_model(__UpperCAmelCase   ,				**__UpperCAmelCase      )
											__a				:	int			=				AutoConfig.for_model(__UpperCAmelCase   ,				**__UpperCAmelCase      )
											__a				:	List[Any]			=				MusicgenDecoderConfig(**__UpperCAmelCase      )
											__a				:	Optional[int]			=				True



						@classmethod
						def 					UpperCAmelCase__				(cls:				Union[str, Any]   ,				__UpperCAmelCase:				PretrainedConfig   ,				__UpperCAmelCase:				PretrainedConfig   ,				__UpperCAmelCase:				MusicgenDecoderConfig   ,				**__UpperCAmelCase:				Any   ,				)						->    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 					UpperCAmelCase__				(self:				List[str]      )						->    int:




											'''simple docstring'''



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





