





import copy

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


UpperCAmelCase_       : List[str]							=    logging.get_logger(__name__)

UpperCAmelCase_       : str							=    {
    """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   lowercase__     (				__A	):
  __UpperCamelCase						  =	"""musicgen_decoder"""
  __UpperCamelCase						  =	["""past_key_values"""]







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





class   lowercase__     (				__A	):
  __UpperCamelCase						  =	"""musicgen"""
  __UpperCamelCase						  =	True







  def __init__(						self     ,    **_lowercase    ):
       super().__init__(**_lowercase    )
       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_       :							List[Any]			 =		text_encoder_config.pop("""model_type"""    )

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

       lowerCAmelCase_       :							List[str]			 =		kwargs.pop("""decoder"""    )

       lowerCAmelCase_       :							Any			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    )
       lowerCAmelCase_       :							List[str]			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    )
       lowerCAmelCase_       :							Dict			 =		MusicgenDecoderConfig(**_lowercase    )
       lowerCAmelCase_       :							int			 =		True







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







  def 						UpperCAmelCase__		(						self    ):
       lowerCAmelCase_       :							List[str]			 =		copy.deepcopy(self.__dict__    )
       lowerCAmelCase_       :							Any			 =		self.text_encoder.to_dict()
       lowerCAmelCase_       :							Any			 =		self.audio_encoder.to_dict()
       lowerCAmelCase_       :							List[str]			 =		self.decoder.to_dict()
       lowerCAmelCase_       :							Optional[int]			 =		self.__class__.model_type
       return output







import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig
from ..clip.configuration_clip import CLIPVisionConfig


UpperCAmelCase_       : Union[str, Any]							=    logging.get_logger(__name__)





class   lowercase__     (				__A	):
  __UpperCamelCase						  =	"""vision-text-dual-encoder"""
  __UpperCamelCase						  =	True







  def __init__(						self     ,    _lowercase=512     ,    _lowercase=2.6592     ,    **_lowercase    ):
       super().__init__(**_lowercase    )

       if "vision_config" not in kwargs:
            raise ValueError("""`vision_config` can not be `None`."""    )

       if "text_config" not in kwargs:
            raise ValueError("""`text_config` can not be `None`."""    )

       lowerCAmelCase_       :							Dict			 =		kwargs.pop("""vision_config"""    )
       lowerCAmelCase_       :							Optional[int]			 =		kwargs.pop("""text_config"""    )

       lowerCAmelCase_       :							Tuple			 =		vision_config.pop("""model_type"""    )
       lowerCAmelCase_       :							str			 =		text_config.pop("""model_type"""    )

       if vision_model_type == "clip":
            lowerCAmelCase_       :							Dict			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    ).vision_config
       elif vision_model_type == "clip_vision_model":
            lowerCAmelCase_       :							Any			 =		CLIPVisionConfig(**_lowercase    )
       else:
            lowerCAmelCase_       :							Tuple			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    )

       lowerCAmelCase_       :							List[Any]			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    )

       lowerCAmelCase_       :							Union[str, Any]			 =		projection_dim
       lowerCAmelCase_       :							Optional[int]			 =		logit_scale_init_value







  @classmethod
  def 						UpperCAmelCase__		(						cls     ,    _lowercase     ,    _lowercase     ,    **_lowercase    ):
       return cls(vision_config=vision_config.to_dict()     ,    text_config=text_config.to_dict()     ,    **_lowercase    )







  def 						UpperCAmelCase__		(						self    ):
       lowerCAmelCase_       :							int			 =		copy.deepcopy(self.__dict__    )
       lowerCAmelCase_       :							List[str]			 =		self.vision_config.to_dict()
       lowerCAmelCase_       :							List[str]			 =		self.text_config.to_dict()
       lowerCAmelCase_       :							str			 =		self.__class__.model_type
       return output
