




'''simple docstring'''



import copy

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


UpperCAmelCase_       :  int      =		logging.get_logger(__name__)

UpperCAmelCase_       :  Tuple      =		{
    '''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):
       __lowercase  :      Union[str, Any]        =			'''musicgen_decoder'''
       __lowercase  :      Any        =			['''past_key_values''']


       def __init__(   self    ,  __SCREAMING_SNAKE_CASE=2048    ,  __SCREAMING_SNAKE_CASE=2048    ,  __SCREAMING_SNAKE_CASE=24    ,  __SCREAMING_SNAKE_CASE=4096    ,  __SCREAMING_SNAKE_CASE=16    ,  __SCREAMING_SNAKE_CASE=0.0    ,  __SCREAMING_SNAKE_CASE=True    ,  __SCREAMING_SNAKE_CASE="gelu"    ,  __SCREAMING_SNAKE_CASE=1024    ,  __SCREAMING_SNAKE_CASE=0.1    ,  __SCREAMING_SNAKE_CASE=0.0    ,  __SCREAMING_SNAKE_CASE=0.0    ,  __SCREAMING_SNAKE_CASE=0.02    ,  __SCREAMING_SNAKE_CASE=False    ,  __SCREAMING_SNAKE_CASE=4    ,  __SCREAMING_SNAKE_CASE=2048    ,  __SCREAMING_SNAKE_CASE=2048    ,  __SCREAMING_SNAKE_CASE=None    ,  __SCREAMING_SNAKE_CASE=False    ,  **__SCREAMING_SNAKE_CASE    ,  )      ->  int:



            '''simple docstring'''




            __snake_case    					=  vocab_size
            __snake_case    					=  max_position_embeddings
            __snake_case    					=  hidden_size
            __snake_case    					=  ffn_dim
            __snake_case    					=  num_hidden_layers
            __snake_case    					=  num_attention_heads
            __snake_case    					=  dropout
            __snake_case    					=  attention_dropout
            __snake_case    					=  activation_dropout
            __snake_case    					=  activation_function
            __snake_case    					=  initializer_factor
            __snake_case    					=  layerdrop
            __snake_case    					=  use_cache
            __snake_case    					=  scale_embedding  # scale factor will be sqrt(d_model) if True
            __snake_case    					=  num_codebooks
            super().__init__(
                pad_token_id=__SCREAMING_SNAKE_CASE    ,  bos_token_id=__SCREAMING_SNAKE_CASE    ,  eos_token_id=__SCREAMING_SNAKE_CASE    ,  tie_word_embeddings=__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE    ,  )





class     lowerCAmelCase   ( __lowerCAmelCase):
       __lowercase  :      Optional[Any]        =			'''musicgen'''
       __lowercase  :      Optional[int]        =			True


       def __init__(   self    ,  **__SCREAMING_SNAKE_CASE  )      ->  Optional[int]:



            '''simple docstring'''




            super().__init__(**__SCREAMING_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    					=  kwargs.pop('''text_encoder'''  )
            __snake_case    					=  text_encoder_config.pop('''model_type'''  )

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

            __snake_case    					=  kwargs.pop('''decoder'''  )

            __snake_case    					=  AutoConfig.for_model(__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )
            __snake_case    					=  AutoConfig.for_model(__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )
            __snake_case    					=  MusicgenDecoderConfig(**__SCREAMING_SNAKE_CASE  )
            __snake_case    					=  True


       @classmethod
       def       lowerCAmelCase      (   cls    ,  __SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE    ,  )      ->  Any:



            '''simple docstring'''




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




       def       lowerCAmelCase      (   self  )      ->  Dict:



            '''simple docstring'''




            __snake_case    					=  copy.deepcopy(self.__dict__  )
            __snake_case    					=  self.text_encoder.to_dict()
            __snake_case    					=  self.audio_encoder.to_dict()
            __snake_case    					=  self.decoder.to_dict()
            __snake_case    					=  self.__class__.model_type
            return output












'''simple docstring'''



from ..utils import deprecate
from .attention_processor import (  # noqa: F401
    Attention,
    AttentionProcessor,
    AttnAddedKVProcessor,
    AttnProcessor2_0,
    LoRAAttnProcessor,
    LoRALinearLayer,
    LoRAXFormersAttnProcessor,
    SlicedAttnAddedKVProcessor,
    SlicedAttnProcessor,
    XFormersAttnProcessor,
)
from .attention_processor import AttnProcessor as AttnProcessorRename  # noqa: F401


deprecate(
    '''cross_attention''',
    '''0.20.0''',
    '''Importing from cross_attention is deprecated. Please import from diffusers.models.attention_processor instead.''',
    standard_warn=False,
)


UpperCAmelCase_       :  Optional[int]      =		AttentionProcessor





class     lowerCAmelCase   ( __lowerCAmelCase):


       def __init__(   self    ,  *__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )      ->  Optional[int]:



            '''simple docstring'''




            __snake_case    					=  F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"  )  )} instead.'''
            deprecate('''cross_attention'''    ,  '''0.20.0'''    ,  __SCREAMING_SNAKE_CASE    ,  standard_warn=__SCREAMING_SNAKE_CASE  )
            super().__init__(*__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )





class     lowerCAmelCase   ( __lowerCAmelCase):


       def __init__(   self    ,  *__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )      ->  Any:



            '''simple docstring'''




            __snake_case    					=  F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"  )  )} instead.'''
            deprecate('''cross_attention'''    ,  '''0.20.0'''    ,  __SCREAMING_SNAKE_CASE    ,  standard_warn=__SCREAMING_SNAKE_CASE  )
            super().__init__(*__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )





class     lowerCAmelCase   ( __lowerCAmelCase):


       def __init__(   self    ,  *__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )      ->  Tuple:



            '''simple docstring'''




            __snake_case    					=  F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"  )  )} instead.'''
            deprecate('''cross_attention'''    ,  '''0.20.0'''    ,  __SCREAMING_SNAKE_CASE    ,  standard_warn=__SCREAMING_SNAKE_CASE  )
            super().__init__(*__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )





class     lowerCAmelCase   ( __lowerCAmelCase):


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



            '''simple docstring'''




            __snake_case    					=  F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"  )  )} instead.'''
            deprecate('''cross_attention'''    ,  '''0.20.0'''    ,  __SCREAMING_SNAKE_CASE    ,  standard_warn=__SCREAMING_SNAKE_CASE  )
            super().__init__(*__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )





class     lowerCAmelCase   ( __lowerCAmelCase):


       def __init__(   self    ,  *__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )      ->  Optional[int]:



            '''simple docstring'''




            __snake_case    					=  F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"  )  )} instead.'''
            deprecate('''cross_attention'''    ,  '''0.20.0'''    ,  __SCREAMING_SNAKE_CASE    ,  standard_warn=__SCREAMING_SNAKE_CASE  )
            super().__init__(*__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )





class     lowerCAmelCase   ( __lowerCAmelCase):


       def __init__(   self    ,  *__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )      ->  Tuple:



            '''simple docstring'''




            __snake_case    					=  F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"  )  )} instead.'''
            deprecate('''cross_attention'''    ,  '''0.20.0'''    ,  __SCREAMING_SNAKE_CASE    ,  standard_warn=__SCREAMING_SNAKE_CASE  )
            super().__init__(*__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )





class     lowerCAmelCase   ( __lowerCAmelCase):


       def __init__(   self    ,  *__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )      ->  int:



            '''simple docstring'''




            __snake_case    					=  F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"  )  )} instead.'''
            deprecate('''cross_attention'''    ,  '''0.20.0'''    ,  __SCREAMING_SNAKE_CASE    ,  standard_warn=__SCREAMING_SNAKE_CASE  )
            super().__init__(*__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )





class     lowerCAmelCase   ( __lowerCAmelCase):


       def __init__(   self    ,  *__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )      ->  List[str]:



            '''simple docstring'''




            __snake_case    					=  F'''{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"  )  )} instead.'''
            deprecate('''cross_attention'''    ,  '''0.20.0'''    ,  __SCREAMING_SNAKE_CASE    ,  standard_warn=__SCREAMING_SNAKE_CASE  )
            super().__init__(*__SCREAMING_SNAKE_CASE    ,  **__SCREAMING_SNAKE_CASE  )






