





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_				(		a_						):
  A_										=    'musicgen_decoder'
  A_										=    ['past_key_values']






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






   '''simple docstring'''

   __lowerCAmelCase     :       Dict						=   vocab_size
   __lowerCAmelCase     :       Union[str, Any]						=   max_position_embeddings
   __lowerCAmelCase     :       List[Any]						=   hidden_size
   __lowerCAmelCase     :       Any						=   ffn_dim
   __lowerCAmelCase     :       Optional[Any]						=   num_hidden_layers
   __lowerCAmelCase     :       Optional[Any]						=   num_attention_heads
   __lowerCAmelCase     :       Optional[int]						=   dropout
   __lowerCAmelCase     :       Optional[Any]						=   attention_dropout
   __lowerCAmelCase     :       Optional[Any]						=   activation_dropout
   __lowerCAmelCase     :       List[str]						=   activation_function
   __lowerCAmelCase     :       Optional[int]						=   initializer_factor
   __lowerCAmelCase     :       Any						=   layerdrop
   __lowerCAmelCase     :       Optional[Any]						=   use_cache
   __lowerCAmelCase     :       Dict						=   scale_embedding  # scale factor will be sqrt(d_model) if True
   __lowerCAmelCase     :       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    snake_case_				(		a_						):
  A_										=    'musicgen'
  A_										=    True






  def __init__(							self :     Dict   ,  **_snake_case :     Optional[Any]			)->Any:






   '''simple docstring'''

   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"""			)

   __lowerCAmelCase     :       List[Any]						=   kwargs.pop("""text_encoder"""			)
   __lowerCAmelCase     :       Tuple						=   text_encoder_config.pop("""model_type"""			)

   __lowerCAmelCase     :       int						=   kwargs.pop("""audio_encoder"""			)
   __lowerCAmelCase     :       List[str]						=   audio_encoder_config.pop("""model_type"""			)

   __lowerCAmelCase     :       List[Any]						=   kwargs.pop("""decoder"""			)

   __lowerCAmelCase     :       Optional[int]						=   AutoConfig.for_model(_snake_case   ,  **_snake_case			)
   __lowerCAmelCase     :       str						=   AutoConfig.for_model(_snake_case   ,  **_snake_case			)
   __lowerCAmelCase     :       List[str]						=   MusicgenDecoderConfig(**_snake_case			)
   __lowerCAmelCase     :       str						=   True






  @classmethod
  def       UpperCAmelCase__						(							cls :     str   ,  _snake_case :     PretrainedConfig   ,  _snake_case :     PretrainedConfig   ,  _snake_case :     MusicgenDecoderConfig   ,  **_snake_case :     Optional[int]   ,  )->List[str]:






   '''simple docstring'''

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






  def       UpperCAmelCase__						(							self :     int			)->Optional[Any]:






   '''simple docstring'''

   __lowerCAmelCase     :       Any						=   copy.deepcopy(self.__dict__			)
   __lowerCAmelCase     :       Dict						=   self.text_encoder.to_dict()
   __lowerCAmelCase     :       Tuple						=   self.audio_encoder.to_dict()
   __lowerCAmelCase     :       List[str]						=   self.decoder.to_dict()
   __lowerCAmelCase     :       str						=   self.__class__.model_type
   return output
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCAmelCase							= {'''configuration_nat''': ['''NAT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NatConfig''']}


try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase							= [
     '''NAT_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''NatForImageClassification''',
     '''NatModel''',
     '''NatPreTrainedModel''',
     '''NatBackbone''',
 ]

if TYPE_CHECKING:
 from .configuration_nat import NAT_PRETRAINED_CONFIG_ARCHIVE_MAP, NatConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_nat import (
      NAT_PRETRAINED_MODEL_ARCHIVE_LIST,
      NatBackbone,
      NatForImageClassification,
      NatModel,
      NatPreTrainedModel,
  )

else:
 import sys

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



