

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__							=				"\n    This is the configuration class to store the configuration of a [`{model}`]. It is used to instantiate the model\n    according to the specified arguments, defining the model architecture. Instantiating a configuration with the\n    defaults will yield a similar configuration to that of the Bark [suno/bark](https://huggingface.co/suno/bark)\n    architecture.\n\n    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the\n    documentation from [`PretrainedConfig`] for more information.\n\n    Args:\n        block_size (`int`, *optional*, defaults to 1024):\n            The maximum sequence length that this model might ever be used with. Typically set this to something large\n            just in case (e.g., 512 or 1024 or 2048).\n        input_vocab_size (`int`, *optional*, defaults to 10_048):\n            Vocabulary size of a Bark sub-model. Defines the number of different tokens that can be represented by the\n            `inputs_ids` passed when calling [`{model}`]. Defaults to 10_048 but should be carefully thought with\n            regards to the chosen sub-model.\n        output_vocab_size (`int`, *optional*, defaults to 10_048):\n            Output vocabulary size of a Bark sub-model. Defines the number of different tokens that can be represented\n            by the: `output_ids` when passing forward a [`{model}`]. Defaults to 10_048 but should be carefully thought\n            with regards to the chosen sub-model.\n        num_layers (`int`, *optional*, defaults to 12):\n            Number of hidden layers in the given sub-model.\n        num_heads (`int`, *optional*, defaults to 12):\n            Number of attention heads for each attention layer in the Transformer architecture.\n        hidden_size (`int`, *optional*, defaults to 768):\n            Dimensionality of the \"intermediate\" (often named feed-forward) layer in the architecture.\n        dropout (`float`, *optional*, defaults to 0.0):\n            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.\n        bias (`bool`, *optional*, defaults to `True`):\n            Whether or not to use bias in the linear layers and layer norm layers.\n        initializer_range (`float`, *optional*, defaults to 0.02):\n            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.\n        use_cache (`bool`, *optional*, defaults to `True`):\n            Whether or not the model should return the last key/values attentions (not used by all models).\n"

class 					__UpperCamelCase					(       SCREAMING_SNAKE_CASE      ):
	_lowercase	: List[Any]												=	"bark_module"
	_lowercase	: int												=	["past_key_values"]

	_lowercase	: Dict												=	{
	    "num_attention_heads": "num_heads",
	    "num_hidden_layers": "num_layers",
	    "vocab_size": "input_vocab_size",
	    "window_size": "block_size",
	}







	def __init__( self:			int	,			__UpperCamelCase:			Dict=10_24	,			__UpperCamelCase:			Optional[Any]=1_00_48	,			__UpperCamelCase:			List[str]=1_00_48	,			__UpperCamelCase:			str=12	,			__UpperCamelCase:			Tuple=12	,			__UpperCamelCase:			Any=7_68	,			__UpperCamelCase:			Tuple=0.0	,			__UpperCamelCase:			Optional[Any]=True	,			__UpperCamelCase:			Tuple=0.02	,			__UpperCamelCase:			int=True	,			**__UpperCamelCase:			List[Any]	,			):

						'''simple docstring'''





						__magic_name__				=     block_size
						__magic_name__				=     input_vocab_size
						__magic_name__				=     output_vocab_size
						__magic_name__				=     num_layers
						__magic_name__				=     num_heads
						__magic_name__				=     hidden_size
						__magic_name__				=     dropout
						__magic_name__				=     bias
						__magic_name__				=     use_cache
						__magic_name__				=     initializer_range

						super().__init__(**__UpperCamelCase   )







	@classmethod
	def 						_SCREAMING_SNAKE_CASE				( cls:			str	,			__UpperCamelCase:			Union[str, os.PathLike]	,			__UpperCamelCase:			Optional[Union[str, os.PathLike]] = None	,			__UpperCamelCase:			bool = False	,			__UpperCamelCase:			bool = False	,			__UpperCamelCase:			Optional[Union[str, bool]] = None	,			__UpperCamelCase:			str = "main"	,			**__UpperCamelCase:			Dict	,			):

						'''simple docstring'''





						__magic_name__				=     cache_dir
						__magic_name__				=     force_download
						__magic_name__				=     local_files_only
						__magic_name__				=     revision

						cls._set_token_in_kwargs(__UpperCamelCase	,			__UpperCamelCase   )

						__magic_name__,						__magic_name__				=     cls.get_config_dict(__UpperCamelCase	,			**__UpperCamelCase   )

						# get the config dict if we are loading from Bark
						if config_dict.get('model_type'   ) == "bark":
											__magic_name__				=     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(__UpperCamelCase	,			**__UpperCamelCase   )




@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					(       SCREAMING_SNAKE_CASE      ):
	_lowercase	: List[Any]												=	"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					(       SCREAMING_SNAKE_CASE      ):
	_lowercase	: List[str]												=	"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					(       SCREAMING_SNAKE_CASE      ):
	_lowercase	: Optional[Any]												=	"fine_acoustics"







	def __init__( self:			str	,			__UpperCamelCase:			Tuple=True	,			__UpperCamelCase:			Dict=8	,			__UpperCamelCase:			List[Any]=1	,			**__UpperCamelCase:			int   ):

						'''simple docstring'''





						__magic_name__				=     n_codes_total
						__magic_name__				=     n_codes_given

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




class 					__UpperCamelCase					(       SCREAMING_SNAKE_CASE      ):
	_lowercase	: int												=	"bark"
	_lowercase	: List[Any]												=	True







	def __init__( self:			Any	,			__UpperCamelCase:			Dict = None	,			__UpperCamelCase:			Dict = None	,			__UpperCamelCase:			Dict = None	,			__UpperCamelCase:			Dict = None	,			__UpperCamelCase:			str=0.02	,			**__UpperCamelCase:			List[Any]	,			):

						'''simple docstring'''





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

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

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

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

						__magic_name__				=     BarkSemanticConfig(**__UpperCamelCase   )
						__magic_name__				=     BarkCoarseConfig(**__UpperCamelCase   )
						__magic_name__				=     BarkFineConfig(**__UpperCamelCase   )
						__magic_name__				=     AutoConfig.for_model(**__UpperCamelCase   )

						__magic_name__				=     initializer_range

						super().__init__(**__UpperCamelCase   )







	@classmethod
	def 						_SCREAMING_SNAKE_CASE				( cls:			List[str]	,			__UpperCamelCase:			BarkSemanticConfig	,			__UpperCamelCase:			BarkCoarseConfig	,			__UpperCamelCase:			BarkFineConfig	,			__UpperCamelCase:			AutoConfig	,			**__UpperCamelCase:			Optional[int]	,			):

						'''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()	,			**__UpperCamelCase	,			)







	def 						_SCREAMING_SNAKE_CASE				( self:			Any   ):

						'''simple docstring'''





						__magic_name__				=     copy.deepcopy(self.__dict__   )

						__magic_name__				=     self.semantic_config.to_dict()
						__magic_name__				=     self.coarse_acoustics_config.to_dict()
						__magic_name__				=     self.fine_acoustics_config.to_dict()
						__magic_name__				=     self.codec_config.to_dict()

						__magic_name__				=     self.__class__.model_type
						return output







from collections import OrderedDict
from typing import Mapping

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


A__							=				logging.get_logger(__name__)

A__							=				{
    "nghuyong/ernie-1.0-base-zh": "https://huggingface.co/nghuyong/ernie-1.0-base-zh/resolve/main/config.json",
    "nghuyong/ernie-2.0-base-en": "https://huggingface.co/nghuyong/ernie-2.0-base-en/resolve/main/config.json",
    "nghuyong/ernie-2.0-large-en": "https://huggingface.co/nghuyong/ernie-2.0-large-en/resolve/main/config.json",
    "nghuyong/ernie-3.0-base-zh": "https://huggingface.co/nghuyong/ernie-3.0-base-zh/resolve/main/config.json",
    "nghuyong/ernie-3.0-medium-zh": "https://huggingface.co/nghuyong/ernie-3.0-medium-zh/resolve/main/config.json",
    "nghuyong/ernie-3.0-mini-zh": "https://huggingface.co/nghuyong/ernie-3.0-mini-zh/resolve/main/config.json",
    "nghuyong/ernie-3.0-micro-zh": "https://huggingface.co/nghuyong/ernie-3.0-micro-zh/resolve/main/config.json",
    "nghuyong/ernie-3.0-nano-zh": "https://huggingface.co/nghuyong/ernie-3.0-nano-zh/resolve/main/config.json",
    "nghuyong/ernie-gram-zh": "https://huggingface.co/nghuyong/ernie-gram-zh/resolve/main/config.json",
    "nghuyong/ernie-health-zh": "https://huggingface.co/nghuyong/ernie-health-zh/resolve/main/config.json",
}

class 					__UpperCamelCase					(       SCREAMING_SNAKE_CASE      ):
	_lowercase	: Dict												=	"ernie"







	def __init__( self:			List[Any]	,			__UpperCamelCase:			Dict=3_05_22	,			__UpperCamelCase:			str=7_68	,			__UpperCamelCase:			Tuple=12	,			__UpperCamelCase:			int=12	,			__UpperCamelCase:			Optional[Any]=30_72	,			__UpperCamelCase:			str="gelu"	,			__UpperCamelCase:			Any=0.1	,			__UpperCamelCase:			int=0.1	,			__UpperCamelCase:			int=5_12	,			__UpperCamelCase:			Any=2	,			__UpperCamelCase:			Tuple=3	,			__UpperCamelCase:			Any=False	,			__UpperCamelCase:			Optional[int]=0.02	,			__UpperCamelCase:			List[Any]=1E-12	,			__UpperCamelCase:			Union[str, Any]=0	,			__UpperCamelCase:			Tuple="absolute"	,			__UpperCamelCase:			Union[str, Any]=True	,			__UpperCamelCase:			Optional[Any]=None	,			**__UpperCamelCase:			List[Any]	,			):

						'''simple docstring'''





						super().__init__(pad_token_id=__UpperCamelCase	,			**__UpperCamelCase   )

						__magic_name__				=     vocab_size
						__magic_name__				=     hidden_size
						__magic_name__				=     num_hidden_layers
						__magic_name__				=     num_attention_heads
						__magic_name__				=     hidden_act
						__magic_name__				=     intermediate_size
						__magic_name__				=     hidden_dropout_prob
						__magic_name__				=     attention_probs_dropout_prob
						__magic_name__				=     max_position_embeddings
						__magic_name__				=     type_vocab_size
						__magic_name__				=     task_type_vocab_size
						__magic_name__				=     use_task_id
						__magic_name__				=     initializer_range
						__magic_name__				=     layer_norm_eps
						__magic_name__				=     position_embedding_type
						__magic_name__				=     use_cache
						__magic_name__				=     classifier_dropout




class 					__UpperCamelCase					(       SCREAMING_SNAKE_CASE      ):







	@property
	def 						_SCREAMING_SNAKE_CASE				( self:			Tuple   ):

						'''simple docstring'''





						if self.task == "multiple-choice":
											__magic_name__				=     {0: 'batch', 1: 'choice', 2: 'sequence'}
						else:
											__magic_name__				=     {0: 'batch', 1: 'sequence'}
						return OrderedDict(
						    [
						        ('input_ids', dynamic_axis),
						        ('attention_mask', dynamic_axis),
						        ('token_type_ids', dynamic_axis),
						        ('task_type_ids', dynamic_axis),
						    ]   )




