
    <h.                     z   S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	J
r
  \R                  " \5      rSr " S	 S
\5      r\" \R!                  SSS9S5       " S S\5      5       r\" \R!                  SSS9S5       " S S\5      5       r\" \R!                  SSS9S5       " S S\5      5       r " S S\5      r/ SQrg)zBARK model configuration    )Optional   )PretrainedConfig)add_start_docstringslogging   )CONFIG_MAPPING
AutoConfiga
  
    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).
c                   T   ^  \ rS rSrS/rSSSSS.r          S
U 4S jjrS	rU =r$ )BarkSubModelConfigA   past_key_values	num_heads
num_layersinput_vocab_size
block_size)num_attention_headsnum_hidden_layers
vocab_sizewindow_sizec                    > Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        [        TU ],  " S0 UD6  g )N )r   r   output_vocab_sizer   r   hidden_sizedropoutbias	use_cacheinitializer_rangesuper__init__)selfr   r   r   r   r   r   r   r   r   r   kwargs	__class__s               c/var/www/html/shao/venv/lib/python3.13/site-packages/transformers/models/bark/configuration_bark.pyr    BarkSubModelConfig.__init__K   sK     % 0!2$"&	"!2"6"    )
r   r   r   r   r   r   r   r   r   r   )
i   @'  r'      r(   i   g        T{Gz?T)	__name__
__module____qualname____firstlineno__keys_to_ignore_at_inferenceattribute_mapr    __static_attributes____classcell__r#   s   @r$   r   r   A   sK    #4"5  +)(#	M  # #r&   r   BarkSemanticConfigBarkSemanticModel)configmodela  
    Example:

    ```python
    >>> from transformers import BarkSemanticConfig, BarkSemanticModel

    >>> # Initializing a Bark sub-module style configuration
    >>> configuration = BarkSemanticConfig()

    >>> # Initializing a model (with random weights) from the suno/bark style configuration
    >>> model = BarkSemanticModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```c                       \ rS rSrSrSrSrg)r3   g   semanticsemantic_configr   Nr*   r+   r,   r-   
model_typebase_config_keyr0   r   r&   r$   r3   r3   g   s    & J'Or&   BarkCoarseConfigBarkCoarseModela  
    Example:

    ```python
    >>> from transformers import BarkCoarseConfig, BarkCoarseModel

    >>> # Initializing a Bark sub-module style configuration
    >>> configuration = BarkCoarseConfig()

    >>> # Initializing a model (with random weights) from the suno/bark style configuration
    >>> model = BarkCoarseModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```c                       \ rS rSrSrSrSrg)r>   ~   coarse_acousticscoarse_acoustics_configr   Nr;   r   r&   r$   r>   r>   ~   s    & $J/Or&   BarkFineConfigBarkFineModela   
        n_codes_total (`int`, *optional*, defaults to 8):
            The total number of audio codebooks predicted. Used in the fine acoustics sub-model.
        n_codes_given (`int`, *optional*, defaults to 1):
            The number of audio codebooks predicted in the coarse acoustics sub-model. Used in the acoustics
            sub-models.
    Example:

    ```python
    >>> from transformers import BarkFineConfig, BarkFineModel

    >>> # Initializing a Bark sub-module style configuration
    >>> configuration = BarkFineConfig()

    >>> # Initializing a model (with random weights) from the suno/bark style configuration
    >>> model = BarkFineModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```c                   4   ^  \ rS rSrSrSrSU 4S jjrSrU =r$ )rD      fine_acousticsfine_acoustics_configc                 B   > X l         X0l        [        TU ]  " SSU0UD6  g )Ntie_word_embeddingsr   )n_codes_totaln_codes_givenr   r    )r!   rK   rL   rM   r"   r#   s        r$   r    BarkFineConfig.__init__   s%    **K-@KFKr&   )rM   rL   )T      )	r*   r+   r,   r-   r<   r=   r    r0   r1   r2   s   @r$   rD   rD      s    0 "J-OL Lr&   c            
          ^  \ rS rSrSrSr\\\\	S.r
     SS\\   S\\   S\\   S\\   4U 4S	 jjjr\S\S\S\S\4S
 j5       rSrU =r$ )
BarkConfig   a  
This is the configuration class to store the configuration of a [`BarkModel`]. It is used to instantiate a Bark
model according to the specified sub-models configurations, 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:
semantic_config ([`BarkSemanticConfig`], *optional*):
    Configuration of the underlying semantic sub-model.
coarse_acoustics_config ([`BarkCoarseConfig`], *optional*):
    Configuration of the underlying coarse acoustics sub-model.
fine_acoustics_config ([`BarkFineConfig`], *optional*):
    Configuration of the underlying fine acoustics sub-model.
codec_config ([`AutoConfig`], *optional*):
    Configuration of the underlying codec sub-model.

Example:

```python
>>> from transformers import (
...     BarkSemanticConfig,
...     BarkCoarseConfig,
...     BarkFineConfig,
...     BarkModel,
...     BarkConfig,
...     AutoConfig,
... )

>>> # Initializing Bark sub-modules configurations.
>>> semantic_config = BarkSemanticConfig()
>>> coarse_acoustics_config = BarkCoarseConfig()
>>> fine_acoustics_config = BarkFineConfig()
>>> codec_config = AutoConfig.from_pretrained("facebook/encodec_24khz")


>>> # Initializing a Bark module style configuration
>>> configuration = BarkConfig.from_sub_model_configs(
...     semantic_config, coarse_acoustics_config, fine_acoustics_config, codec_config
... )

>>> # Initializing a model (with random weights)
>>> model = BarkModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```
barkr:   rC   rI   codec_configr:   rC   rI   rV   c                   > Uc  0 n[         R                  S5        Uc  0 n[         R                  S5        Uc  0 n[         R                  S5        Uc  0 n[         R                  S5        [        S0 UD6U l        [	        S0 UD6U l        [        S0 UD6U l        UR                  SS5      n[        U   " S0 UD6U l
        XPl        [        TU ]4  " S0 UD6  g )NzMsemantic_config is None. initializing the semantic model with default values.zScoarse_acoustics_config is None. initializing the coarse model with default values.zOfine_acoustics_config is None. initializing the fine model with default values.zGcodec_config is None. initializing the codec model with default values.r<   encodecr   )loggerinfor3   r:   r>   rC   rD   rI   getr	   rV   r   r   r    )	r!   r:   rC   rI   rV   r   r"   codec_model_typer#   s	           r$   r    BarkConfig.__init__   s     " OKKgh"*&(#KKmn ($&!KKijLKKab1DOD'7'R:Q'R$%3%L6K%L"'++L)D*+;<L|L!2"6"r&   c                     U " SUR                  5       UR                  5       UR                  5       UR                  5       S.UD6$ )z
Instantiate a [`BarkConfig`] (or a derived class) from bark sub-models configuration.

Returns:
    [`BarkConfig`]: An instance of a configuration object
rU   r   )to_dict)clsr:   rC   rI   rV   r"   s         r$   from_sub_model_configs!BarkConfig.from_sub_model_configs  sP      
+335$;$C$C$E"7"?"?"A%--/	

 
 	
r&   )rC   rV   rI   r   r:   )NNNNr)   )r*   r+   r,   r-   __doc__r<   r3   r>   rD   r
   sub_configsr   dictr    classmethodr   ra   r0   r1   r2   s   @r$   rR   rR      s    2h J-#3!/"	K +/2604'+!#!$!# "*$!#  (~	!#
 tn!# !#F 
+
 "2
  .	

 '
 
r&   rR   )r>   rR   rD   r3   N)rc   typingr   configuration_utilsr   utilsr   r   autor	   r
   
get_loggerr*   rY   #BARK_SUBMODELCONFIG_START_DOCSTRINGr   formatr3   r>   rD   rR   __all__r   r&   r$   <module>ro      s
     3 2 - 
		H	%#' #L##) ##L '..6JRe.f$(+ (%$(
 '..6HPa.b$0) 0%$0
 '..6Fo.^.L' L/.Lu
! u
p Ur&   