


'''simple docstring'''

import copy

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


__lowercase:		List[Any]    						=  logging.get_logger(__name__)

__lowercase:		Dict    						=  {
    "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 			UpperCAmelCase			(							SCREAMING_SNAKE_CASE__):
 _lowerCamelCase			:       str            =       'musicgen_decoder'
 _lowerCamelCase			:       str            =       ['past_key_values']

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





    """simple docstring"""



    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 			UpperCAmelCase			(							SCREAMING_SNAKE_CASE__):
 _lowerCamelCase			:       Optional[Any]            =       'musicgen'
 _lowerCamelCase			:       Optional[Any]            =       True

 def __init__(			self			:						Any,       **a_			:						Any       ):





    """simple docstring"""



    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 		lowercase_    (			cls			:						Optional[Any],       a_			:						PretrainedConfig,       a_			:						PretrainedConfig,       a_			:						MusicgenDecoderConfig,       **a_			:						Tuple,       ):





    """simple docstring"""



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

 def 		lowercase_    (			self			:						int       ):





    """simple docstring"""



    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 collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast
from ...utils import logging


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

__lowercase:		List[Any]    						=  {
    "uclanlp/plbart-base": "https://huggingface.co/uclanlp/plbart-base/resolve/main/config.json",
    # See all PLBART models at https://huggingface.co/models?filter=plbart
}







class 			UpperCAmelCase			(							SCREAMING_SNAKE_CASE__):
 _lowerCamelCase			:       Optional[int]            =       'plbart'
 _lowerCamelCase			:       Union[str, Any]            =       ['past_key_values']
 _lowerCamelCase			:       Tuple            =       {'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}

 def __init__(			self			:						Optional[Any],       a_			:						Union[str, Any]=5_0005,       a_			:						int=1024,       a_			:						str=6,       a_			:						Union[str, Any]=3072,       a_			:						Optional[int]=12,       a_			:						Optional[Any]=6,       a_			:						Dict=3072,       a_			:						Dict=12,       a_			:						int=0.0,       a_			:						List[Any]=0.0,       a_			:						Optional[Any]=True,       a_			:						List[str]=True,       a_			:						Tuple="gelu",       a_			:						Any=768,       a_			:						Dict=0.1,       a_			:						List[Any]=0.1,       a_			:						Union[str, Any]=0.0,       a_			:						Optional[Any]=0.02,       a_			:						Union[str, Any]=0.0,       a_			:						int=True,       a_			:						Dict=1,       a_			:						Optional[int]=0,       a_			:						Optional[int]=2,       a_			:						Any=2,       **a_			:						Optional[Any],       ):





    """simple docstring"""



    UpperCamelCase__			    =    vocab_size
    UpperCamelCase__			    =    max_position_embeddings
    UpperCamelCase__			    =    d_model
    UpperCamelCase__			    =    encoder_ffn_dim
    UpperCamelCase__			    =    encoder_layers
    UpperCamelCase__			    =    encoder_attention_heads
    UpperCamelCase__			    =    decoder_ffn_dim
    UpperCamelCase__			    =    decoder_layers
    UpperCamelCase__			    =    decoder_attention_heads
    UpperCamelCase__			    =    dropout
    UpperCamelCase__			    =    attention_dropout
    UpperCamelCase__			    =    activation_dropout
    UpperCamelCase__			    =    activation_function
    UpperCamelCase__			    =    init_std
    UpperCamelCase__			    =    encoder_layerdrop
    UpperCamelCase__			    =    decoder_layerdrop
    UpperCamelCase__			    =    classifier_dropout
    UpperCamelCase__			    =    use_cache
    UpperCamelCase__			    =    encoder_layers
    UpperCamelCase__			    =    scale_embedding  # scale factor will be sqrt(d_model) if True
    super().__init__(
        pad_token_id=a_,       bos_token_id=a_,       eos_token_id=a_,       is_encoder_decoder=a_,       forced_eos_token_id=a_,       **a_,       )







class 			UpperCAmelCase			(							SCREAMING_SNAKE_CASE__):

 @property
 def 		lowercase_    (			self			:						int       ):





    """simple docstring"""



    return OrderedDict(
        [
            ("input_ids", {0: "batch", 1: "sequence"}),
            ("attention_mask", {0: "batch", 1: "sequence"}),
        ]       )

 @property
 def 		lowercase_    (			self			:						Tuple       ):





    """simple docstring"""



    if self.use_past:
       return OrderedDict(
           [
               ("last_hidden_state", {0: "batch", 1: "sequence"}),
               ("past_keys", {0: "batch", 2: "sequence"}),
               ("encoder_last_hidden_state", {0: "batch", 1: "sequence"}),
           ]       )
    else:
       return OrderedDict(
           [
               ("last_hidden_state", {0: "batch", 1: "sequence"}),
               ("encoder_last_hidden_state", {0: "batch", 1: "sequence"}),
           ]       )