





"""simple docstring"""






import copy

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


lowerCAmelCase_      =				logging.get_logger(__name__)

lowerCAmelCase_      =				{
    '''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       (   snake_case				):
       lowerCAmelCase__    			=	"""musicgen_decoder"""
       lowerCAmelCase__    			=	["""past_key_values"""]






       def __init__( self     ,	a__=20_48     ,	a__=20_48     ,	a__=24     ,	a__=40_96     ,	a__=16     ,	a__=0.0     ,	a__=True     ,	a__="gelu"     ,	a__=10_24     ,	a__=0.1     ,	a__=0.0     ,	a__=0.0     ,	a__=0.02     ,	a__=False     ,	a__=4     ,	a__=20_48     ,	a__=20_48     ,	a__=None     ,	a__=False     ,	**a__     ,	):
              _UpperCAmelCase			     =  vocab_size
              _UpperCAmelCase			     =  max_position_embeddings
              _UpperCAmelCase			     =  hidden_size
              _UpperCAmelCase			     =  ffn_dim
              _UpperCAmelCase			     =  num_hidden_layers
              _UpperCAmelCase			     =  num_attention_heads
              _UpperCAmelCase			     =  dropout
              _UpperCAmelCase			     =  attention_dropout
              _UpperCAmelCase			     =  activation_dropout
              _UpperCAmelCase			     =  activation_function
              _UpperCAmelCase			     =  initializer_factor
              _UpperCAmelCase			     =  layerdrop
              _UpperCAmelCase			     =  use_cache
              _UpperCAmelCase			     =  scale_embedding  # scale factor will be sqrt(d_model) if True
              _UpperCAmelCase			     =  num_codebooks
              super().__init__(
                  pad_token_id=a__     ,	bos_token_id=a__     ,	eos_token_id=a__     ,	tie_word_embeddings=a__     ,	**a__     ,	)



class 						lowerCAmelCase       (   snake_case				):
       lowerCAmelCase__    			=	"""musicgen"""
       lowerCAmelCase__    			=	True






       def __init__( self     ,	**a__  ):
              super().__init__(**a__  )
              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			     =  kwargs.pop('text_encoder'  )
              _UpperCAmelCase			     =  text_encoder_config.pop('model_type'  )

              _UpperCAmelCase			     =  kwargs.pop('audio_encoder'  )
              _UpperCAmelCase			     =  audio_encoder_config.pop('model_type'  )

              _UpperCAmelCase			     =  kwargs.pop('decoder'  )

              _UpperCAmelCase			     =  AutoConfig.for_model(a__     ,	**a__  )
              _UpperCAmelCase			     =  AutoConfig.for_model(a__     ,	**a__  )
              _UpperCAmelCase			     =  MusicgenDecoderConfig(**a__  )
              _UpperCAmelCase			     =  True






       @classmethod
       def 				__A			( cls     ,	a__     ,	a__     ,	a__     ,	**a__     ,	):
              return cls(
                  text_encoder=text_encoder_config.to_dict()     ,	audio_encoder=audio_encoder_config.to_dict()     ,	decoder=decoder_config.to_dict()     ,	**a__     ,	)






       def 				__A			( self  ):
              _UpperCAmelCase			     =  copy.deepcopy(self.__dict__  )
              _UpperCAmelCase			     =  self.text_encoder.to_dict()
              _UpperCAmelCase			     =  self.audio_encoder.to_dict()
              _UpperCAmelCase			     =  self.decoder.to_dict()
              _UpperCAmelCase			     =  self.__class__.model_type
              return output













"""simple docstring"""






from typing import Callable, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase_      =				logging.get_logger(__name__)

lowerCAmelCase_      =				{
    '''microsoft/prophetnet-large-uncased''': (
        '''https://huggingface.co/microsoft/prophetnet-large-uncased/resolve/main/config.json'''
    ),
}



class 						lowerCAmelCase       (   snake_case				):
       lowerCAmelCase__    			=	"""prophetnet"""
       lowerCAmelCase__    			=	["""past_key_values"""]
       lowerCAmelCase__    			=	{
           """num_attention_heads""": """num_encoder_attention_heads""",
       }






       def __init__( self     ,	a__ = 0.1     ,	a__ = "gelu"     ,	a__ = 3_05_22     ,	a__ = 10_24     ,	a__ = 40_96     ,	a__ = 12     ,	a__ = 16     ,	a__ = 40_96     ,	a__ = 12     ,	a__ = 16     ,	a__ = 0.1     ,	a__ = 0.1     ,	a__ = 5_12     ,	a__ = 0.02     ,	a__ = True     ,	a__ = True     ,	a__ = 0     ,	a__ = 2     ,	a__ = 32     ,	a__ = 1_28     ,	a__ = False     ,	a__ = 0.0     ,	a__ = True     ,	a__ = 0     ,	a__ = 1     ,	a__ = 2     ,	**a__     ,	):
              _UpperCAmelCase			     =  vocab_size
              _UpperCAmelCase			     =  hidden_size
              _UpperCAmelCase			     =  encoder_ffn_dim
              _UpperCAmelCase			     =  num_encoder_layers
              _UpperCAmelCase			     =  num_encoder_attention_heads
              _UpperCAmelCase			     =  decoder_ffn_dim
              _UpperCAmelCase			     =  num_decoder_layers
              _UpperCAmelCase			     =  num_decoder_attention_heads
              _UpperCAmelCase			     =  max_position_embeddings
              _UpperCAmelCase			     =  init_std  # Normal(0, this parameter)
              _UpperCAmelCase			     =  activation_function

              # parameters for prophetnet
              _UpperCAmelCase			     =  ngram
              _UpperCAmelCase			     =  num_buckets
              _UpperCAmelCase			     =  relative_max_distance
              _UpperCAmelCase			     =  disable_ngram_loss
              _UpperCAmelCase			     =  eps

              # 3 Types of Dropout
              _UpperCAmelCase			     =  attention_dropout
              _UpperCAmelCase			     =  activation_dropout
              _UpperCAmelCase			     =  dropout

              _UpperCAmelCase			     =  use_cache

              super().__init__(
                  pad_token_id=a__     ,	bos_token_id=a__     ,	eos_token_id=a__     ,	is_encoder_decoder=a__     ,	add_cross_attention=a__     ,	decoder_start_token_id=a__     ,	**a__     ,	)






       @property
       def 				__A			( self  ):
              return self.num_encoder_layers + self.num_decoder_layers






       @num_hidden_layers.setter
       def 				__A			( self     ,	a__  ):
              raise NotImplementedError(
                  'This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and'
                  ' `num_decoder_layers`.'  )






