

"""simple docstring"""
import copy
import os
from typing import Dict, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import add_start_docstrings, logging
from ..auto import AutoConfig


A									=						logging.get_logger(__name__)


A									=						{
    """suno/bark-small""": """https://huggingface.co/suno/bark-small/resolve/main/config.json""",
    """suno/bark""": """https://huggingface.co/suno/bark/resolve/main/config.json""",
}

A									=						"""
    This is the configuration class to store the configuration of a [`{model}`]. It is used to instantiate the model
    according to the specified arguments, defining the model architecture. Instantiating a configuration with the
    defaults will yield a similar configuration to that of the Bark [suno/bark](https://huggingface.co/suno/bark)
    architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        block_size (`int`, *optional*, defaults to 1024):
            The maximum sequence length that this model might ever be used with. Typically set this to something large
            just in case (e.g., 512 or 1024 or 2048).
        input_vocab_size (`int`, *optional*, defaults to 10_048):
            Vocabulary size of a Bark sub-model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`{model}`]. Defaults to 10_048 but should be carefully thought with
            regards to the chosen sub-model.
        output_vocab_size (`int`, *optional*, defaults to 10_048):
            Output vocabulary size of a Bark sub-model. Defines the number of different tokens that can be represented
            by the: `output_ids` when passing forward a [`{model}`]. Defaults to 10_048 but should be carefully thought
            with regards to the chosen sub-model.
        num_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the given sub-model.
        num_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer architecture.
        hidden_size (`int`, *optional*, defaults to 768):
            Dimensionality of the \"intermediate\" (often named feed-forward) layer in the architecture.
        dropout (`float`, *optional*, defaults to 0.0):
            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
        bias (`bool`, *optional*, defaults to `True`):
            Whether or not to use bias in the linear layers and layer norm layers.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models).
"""

class        _UpperCamelCase	(						lowerCamelCase__	):


  """simple docstring"""





  snake_case_        =    'bark_module'
  snake_case_        =    ['past_key_values']

  snake_case_        =    {
      'num_attention_heads': 'num_heads',
      'num_hidden_layers': 'num_layers',
      'vocab_size': 'input_vocab_size',
      'window_size': 'block_size',
  }



  def __init__( self					: Any       ,       snake_case					: str=1024       ,       snake_case					: Union[str, Any]=1_0048       ,       snake_case					: List[Any]=1_0048       ,       snake_case					: List[Any]=12       ,       snake_case					: int=12       ,       snake_case					: List[Any]=768       ,       snake_case					: int=0.0       ,       snake_case					: Tuple=True       ,       snake_case					: List[Any]=0.02       ,       snake_case					: Tuple=True       ,       **snake_case					: Optional[Any]       ,       )	->			Optional[int]:


         '''simple docstring'''





         __magic_name__			:		str        =     block_size
         __magic_name__			:		Any        =     input_vocab_size
         __magic_name__			:		str        =     output_vocab_size
         __magic_name__			:		List[Any]        =     num_layers
         __magic_name__			:		List[str]        =     num_heads
         __magic_name__			:		Union[str, Any]        =     hidden_size
         __magic_name__			:		str        =     dropout
         __magic_name__			:		Any        =     bias
         __magic_name__			:		Tuple        =     use_cache
         __magic_name__			:		Optional[Any]        =     initializer_range

         super().__init__(**snake_case      )




  @classmethod
  def 							_UpperCAmelCase      ( cls					: Union[str, Any]       ,       snake_case					: Union[str, os.PathLike]       ,       snake_case					: Optional[Union[str, os.PathLike]] = None       ,       snake_case					: bool = False       ,       snake_case					: bool = False       ,       snake_case					: Optional[Union[str, bool]] = None       ,       snake_case					: str = "main"       ,       **snake_case					: Union[str, Any]       ,       )	->			"PretrainedConfig":


         '''simple docstring'''





         __magic_name__			:		Any        =     cache_dir
         __magic_name__			:		Optional[int]        =     force_download
         __magic_name__			:		Union[str, Any]        =     local_files_only
         __magic_name__			:		int        =     revision

         cls._set_token_in_kwargs(snake_case       ,       snake_case      )

         __magic_name__       ,							__magic_name__			:		Dict        =     cls.get_config_dict(snake_case       ,       **snake_case      )

         # get the config dict if we are loading from Bark
         if config_dict.get('''model_type'''      ) == "bark":
                __magic_name__			:		List[Any]        =     config_dict[f"""{cls.model_type}_config"""]

         if "model_type" in config_dict and hasattr(cls       ,       '''model_type'''      ) and config_dict["model_type"] != cls.model_type:
                logger.warning(
                    f"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
                    f"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""      )

         return cls.from_dict(snake_case       ,       **snake_case      )

@add_start_docstrings(
    BARK_SUBMODELCONFIG_START_DOCSTRING.format(config='BarkSemanticConfig'   ,				model='BarkSemanticModel'	)   ,				'\n    Example:\n\n    ```python\n    >>> from transformers import BarkSemanticConfig, BarkSemanticModel\n\n    >>> # Initializing a Bark sub-module style configuration\n    >>> configuration = BarkSemanticConfig()\n\n    >>> # Initializing a model (with random weights) from the suno/bark style configuration\n    >>> model = BarkSemanticModel(configuration)\n\n    >>> # Accessing the model configuration\n    >>> configuration = model.config\n    ```'   ,				)
class        _UpperCamelCase	(						lowerCamelCase__	):


  """simple docstring"""





  snake_case_        =    'semantic'

@add_start_docstrings(
    BARK_SUBMODELCONFIG_START_DOCSTRING.format(config='BarkCoarseConfig'   ,				model='BarkCoarseModel'	)   ,				'\n    Example:\n\n    ```python\n    >>> from transformers import BarkCoarseConfig, BarkCoarseModel\n\n    >>> # Initializing a Bark sub-module style configuration\n    >>> configuration = BarkCoarseConfig()\n\n    >>> # Initializing a model (with random weights) from the suno/bark style configuration\n    >>> model = BarkCoarseModel(configuration)\n\n    >>> # Accessing the model configuration\n    >>> configuration = model.config\n    ```'   ,				)
class        _UpperCamelCase	(						lowerCamelCase__	):


  """simple docstring"""





  snake_case_        =    'coarse_acoustics'

@add_start_docstrings(
    BARK_SUBMODELCONFIG_START_DOCSTRING.format(config='BarkFineConfig'   ,				model='BarkFineModel'	)   ,				'\n        n_codes_total (`int`, *optional*, defaults to 8):\n            The total number of audio codebooks predicted. Used in the fine acoustics sub-model.\n        n_codes_given (`int`, *optional*, defaults to 1):\n            The number of audio codebooks predicted in the coarse acoustics sub-model. Used in the acoustics\n            sub-models.\n    Example:\n\n    ```python\n    >>> from transformers import BarkFineConfig, BarkFineModel\n\n    >>> # Initializing a Bark sub-module style configuration\n    >>> configuration = BarkFineConfig()\n\n    >>> # Initializing a model (with random weights) from the suno/bark style configuration\n    >>> model = BarkFineModel(configuration)\n\n    >>> # Accessing the model configuration\n    >>> configuration = model.config\n    ```'   ,				)
class        _UpperCamelCase	(						lowerCamelCase__	):


  """simple docstring"""





  snake_case_        =    'fine_acoustics'



  def __init__( self					: Any       ,       snake_case					: Union[str, Any]=True       ,       snake_case					: Any=8       ,       snake_case					: Union[str, Any]=1       ,       **snake_case					: int      )	->			List[str]:


         '''simple docstring'''





         __magic_name__			:		Tuple        =     n_codes_total
         __magic_name__			:		str        =     n_codes_given

         super().__init__(tie_word_embeddings=snake_case       ,       **snake_case      )

class        _UpperCamelCase	(						lowerCamelCase__	):


  """simple docstring"""





  snake_case_        =    'bark'
  snake_case_        =    True



  def __init__( self					: str       ,       snake_case					: Dict = None       ,       snake_case					: Dict = None       ,       snake_case					: Dict = None       ,       snake_case					: Dict = None       ,       snake_case					: List[Any]=0.02       ,       **snake_case					: int       ,       )	->			Dict:


         '''simple docstring'''





         if semantic_config is None:
                __magic_name__			:		Union[str, Any]        =     {}
                logger.info('''semantic_config is None. initializing the semantic model with default values.'''      )

         if coarse_acoustics_config is None:
                __magic_name__			:		str        =     {}
                logger.info('''coarse_acoustics_config is None. initializing the coarse model with default values.'''      )

         if fine_acoustics_config is None:
                __magic_name__			:		str        =     {}
                logger.info('''fine_acoustics_config is None. initializing the fine model with default values.'''      )

         if codec_config is None:
                __magic_name__			:		Optional[Any]        =     {}
                logger.info('''codec_config is None. initializing the codec model with default values.'''      )

         __magic_name__			:		Tuple        =     BarkSemanticConfig(**snake_case      )
         __magic_name__			:		Dict        =     BarkCoarseConfig(**snake_case      )
         __magic_name__			:		Tuple        =     BarkFineConfig(**snake_case      )
         __magic_name__			:		List[str]        =     AutoConfig.for_model(**snake_case      )

         __magic_name__			:		int        =     initializer_range

         super().__init__(**snake_case      )



  @classmethod
  def 							_UpperCAmelCase      ( cls					: List[Any]       ,       snake_case					: BarkSemanticConfig       ,       snake_case					: BarkCoarseConfig       ,       snake_case					: BarkFineConfig       ,       snake_case					: AutoConfig       ,       **snake_case					: Union[str, Any]       ,       )	->			List[Any]:


         '''simple docstring'''





         return cls(
             semantic_config=semantic_config.to_dict()       ,       coarse_acoustics_config=coarse_acoustics_config.to_dict()       ,       fine_acoustics_config=fine_acoustics_config.to_dict()       ,       codec_config=codec_config.to_dict()       ,       **snake_case       ,       )




  def 							_UpperCAmelCase      ( self					: Dict      )	->			Tuple:


         '''simple docstring'''





         __magic_name__			:		int        =     copy.deepcopy(self.__dict__      )

         __magic_name__			:		int        =     self.semantic_config.to_dict()
         __magic_name__			:		List[str]        =     self.coarse_acoustics_config.to_dict()
         __magic_name__			:		Tuple        =     self.fine_acoustics_config.to_dict()
         __magic_name__			:		List[Any]        =     self.codec_config.to_dict()

         __magic_name__			:		Dict        =     self.__class__.model_type
         return output



"""simple docstring"""
from typing import Callable, Optional, Union

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


A									=						logging.get_logger(__name__)

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

class        _UpperCamelCase	(						lowerCamelCase__	):


  """simple docstring"""





  snake_case_        =    'prophetnet'
  snake_case_        =    ['past_key_values']
  snake_case_        =    {
      'num_attention_heads': 'num_encoder_attention_heads',
  }



  def __init__( self					: Union[str, Any]       ,       snake_case					: Optional[float] = 0.1       ,       snake_case					: Optional[Union[str, Callable]] = "gelu"       ,       snake_case					: Optional[int] = 3_0522       ,       snake_case					: Optional[int] = 1024       ,       snake_case					: Optional[int] = 4096       ,       snake_case					: Optional[int] = 12       ,       snake_case					: Optional[int] = 16       ,       snake_case					: Optional[int] = 4096       ,       snake_case					: Optional[int] = 12       ,       snake_case					: Optional[int] = 16       ,       snake_case					: Optional[float] = 0.1       ,       snake_case					: Optional[float] = 0.1       ,       snake_case					: Optional[int] = 512       ,       snake_case					: Optional[float] = 0.02       ,       snake_case					: Optional[bool] = True       ,       snake_case					: Optional[bool] = True       ,       snake_case					: Optional[int] = 0       ,       snake_case					: Optional[int] = 2       ,       snake_case					: Optional[int] = 32       ,       snake_case					: Optional[int] = 128       ,       snake_case					: Optional[bool] = False       ,       snake_case					: Optional[float] = 0.0       ,       snake_case					: Optional[bool] = True       ,       snake_case					: Optional[int] = 0       ,       snake_case					: Optional[int] = 1       ,       snake_case					: Optional[int] = 2       ,       **snake_case					: Optional[int]       ,       )	->			List[Any]:


         '''simple docstring'''





         __magic_name__			:		Union[str, Any]        =     vocab_size
         __magic_name__			:		Tuple        =     hidden_size
         __magic_name__			:		str        =     encoder_ffn_dim
         __magic_name__			:		Tuple        =     num_encoder_layers
         __magic_name__			:		int        =     num_encoder_attention_heads
         __magic_name__			:		int        =     decoder_ffn_dim
         __magic_name__			:		Optional[int]        =     num_decoder_layers
         __magic_name__			:		str        =     num_decoder_attention_heads
         __magic_name__			:		Optional[Any]        =     max_position_embeddings
         __magic_name__			:		Union[str, Any]        =     init_std  # Normal(0, this parameter)
         __magic_name__			:		Tuple        =     activation_function

         # parameters for prophetnet
         __magic_name__			:		int        =     ngram
         __magic_name__			:		str        =     num_buckets
         __magic_name__			:		Any        =     relative_max_distance
         __magic_name__			:		Optional[int]        =     disable_ngram_loss
         __magic_name__			:		str        =     eps

         # 3 Types of Dropout
         __magic_name__			:		Dict        =     attention_dropout
         __magic_name__			:		Optional[int]        =     activation_dropout
         __magic_name__			:		List[Any]        =     dropout

         __magic_name__			:		str        =     use_cache

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



  @property
  def 							_UpperCAmelCase      ( self					: str      )	->			int:


         '''simple docstring'''





         return self.num_encoder_layers + self.num_decoder_layers




  @num_hidden_layers.setter
  def 							_UpperCAmelCase      ( self					: Dict       ,       snake_case					: int      )	->			Optional[int]:


         '''simple docstring'''





         raise NotImplementedError(
             '''This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and'''
             ''' `num_decoder_layers`.'''      )
