



"""simple docstring"""
import copy

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


__a           =							logging.get_logger(__name__)

__a           =							{
    "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    (     _lowerCAmelCase							):






					'''simple docstring'''





					_A						:     Dict		=	"""musicgen_decoder"""
					_A						:     str		=	["""past_key_values"""]






					def __init__(			self:				List[str]		,	snake_case:				int=2_048		,	snake_case:				Tuple=2_048		,	snake_case:				Any=24		,	snake_case:				Optional[Any]=4_096		,	snake_case:				List[Any]=16		,	snake_case:				int=0.0		,	snake_case:				Dict=True		,	snake_case:				int="gelu"		,	snake_case:				List[Any]=1_024		,	snake_case:				Optional[Any]=0.1		,	snake_case:				List[str]=0.0		,	snake_case:				Optional[int]=0.0		,	snake_case:				int=0.0_2		,	snake_case:				List[Any]=False		,	snake_case:				str=4		,	snake_case:				Union[str, Any]=2_048		,	snake_case:				int=2_048		,	snake_case:				Dict=None		,	snake_case:				Optional[int]=False		,	**snake_case:				Optional[int]		,	)  ->      int:
											snake_case_					:Optional[Any]		=     vocab_size
											snake_case_					:List[Any]		=     max_position_embeddings
											snake_case_					:Optional[Any]		=     hidden_size
											snake_case_					:Optional[Any]		=     ffn_dim
											snake_case_					:Union[str, Any]		=     num_hidden_layers
											snake_case_					:List[str]		=     num_attention_heads
											snake_case_					:Optional[Any]		=     dropout
											snake_case_					:List[str]		=     attention_dropout
											snake_case_					:Any		=     activation_dropout
											snake_case_					:Dict		=     activation_function
											snake_case_					:str		=     initializer_factor
											snake_case_					:Optional[int]		=     layerdrop
											snake_case_					:Union[str, Any]		=     use_cache
											snake_case_					:int		=     scale_embedding  # scale factor will be sqrt(d_model) if True
											snake_case_					:int		=     num_codebooks
											super().__init__(
											    pad_token_id=snake_case		,	bos_token_id=snake_case		,	eos_token_id=snake_case		,	tie_word_embeddings=snake_case		,	**snake_case		,	)

class 							lowerCamelCase    (     _lowerCAmelCase							):






					'''simple docstring'''





					_A						:     List[str]		=	"""musicgen"""
					_A						:     Any		=	True






					def __init__(			self:				Any		,	**snake_case:				Optional[int]		)  ->      Any:
											super().__init__(**snake_case		)
											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"""		)

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

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

											snake_case_					:Tuple		=     kwargs.pop("""decoder"""		)

											snake_case_					:Any		=     AutoConfig.for_model(snake_case		,	**snake_case		)
											snake_case_					:Optional[int]		=     AutoConfig.for_model(snake_case		,	**snake_case		)
											snake_case_					:int		=     MusicgenDecoderConfig(**snake_case		)
											snake_case_					:Optional[Any]		=     True






					@classmethod
					def   lowerCAmelCase_							(			cls:				Dict		,	snake_case:				PretrainedConfig		,	snake_case:				PretrainedConfig		,	snake_case:				MusicgenDecoderConfig		,	**snake_case:				Optional[Any]		,	)  ->      List[Any]:
											return cls(
											    text_encoder=text_encoder_config.to_dict()		,	audio_encoder=audio_encoder_config.to_dict()		,	decoder=decoder_config.to_dict()		,	**snake_case		,	)






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








'''simple docstring'''







from typing import TYPE_CHECKING

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


_A      :     Optional[Any]       	={
    '''configuration_realm''': ['''REALM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''RealmConfig'''],
    '''tokenization_realm''': ['''RealmTokenizer'''],
}

try:
			if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_A      :     str       	=['''RealmTokenizerFast''']

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_A      :     List[Any]       	=[
			    '''REALM_PRETRAINED_MODEL_ARCHIVE_LIST''',
			    '''RealmEmbedder''',
			    '''RealmForOpenQA''',
			    '''RealmKnowledgeAugEncoder''',
			    '''RealmPreTrainedModel''',
			    '''RealmReader''',
			    '''RealmScorer''',
			    '''load_tf_weights_in_realm''',
			]
			_A      :     Union[str, Any]       	=['''RealmRetriever''']


if TYPE_CHECKING:
			from .configuration_realm import REALM_PRETRAINED_CONFIG_ARCHIVE_MAP, RealmConfig
			from .tokenization_realm import RealmTokenizer

			try:
						if not is_tokenizers_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_realm import RealmTokenizerFast

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_realm import (
						    REALM_PRETRAINED_MODEL_ARCHIVE_LIST,
						    RealmEmbedder,
						    RealmForOpenQA,
						    RealmKnowledgeAugEncoder,
						    RealmPreTrainedModel,
						    RealmReader,
						    RealmScorer,
						    load_tf_weights_in_realm,
						)
						from .retrieval_realm import RealmRetriever


else:
			import sys

			_A      :     int       	=_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)

