o
    eik-                     @   s   d Z ddlmZ ddlmZmZ ddlmZmZ e	e
ZdZG dd deZeejd	d
ddG dd	 d	eZeejddddG dd deZeejddddG dd deZG dd deZg dZdS )zBARK model configuration   )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                       sF   e Zd ZdgZdddddZ								
				d fdd	Z  ZS )BarkSubModelConfigpast_key_values	num_heads
num_layersinput_vocab_size
block_size)num_attention_headsnum_hidden_layers
vocab_sizewindow_size   @'                T{Gz?c                    sR   || _ || _|| _|| _|| _|| _|| _|| _|
| _|	| _	t
 jdi | d S 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__r   i/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/transformers/models/bark/configuration_bark.pyr!   H   s   zBarkSubModelConfig.__init__)
r   r   r   r   r   r   r   Tr   T)__name__
__module____qualname__keys_to_ignore_at_inferenceattribute_mapr!   __classcell__r   r   r$   r&   r   >   s$    	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                   @      e Zd ZdZdZdS )r-   semanticsemantic_configNr'   r(   r)   
model_typebase_config_keyr   r   r   r&   r-   d       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                   @   r1   )r8   coarse_acousticscoarse_acoustics_configNr4   r   r   r   r&   r8   {   r7   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                       s&   e Zd ZdZdZd fdd	Z  ZS )	r<   fine_acousticsfine_acoustics_configT      c                    s(   || _ || _|| _t jdi | d S r   )n_codes_totaln_codes_giventie_word_embeddingsr    r!   )r"   rD   rB   rC   r#   r$   r   r&   r!      s   zBarkFineConfig.__init__)Tr@   rA   )r'   r(   r)   r5   r6   r!   r,   r   r   r$   r&   r<      s    c                
       s`   e Zd ZdZdZeeeedZ						dde
dB de
dB de
dB d	e
dB f fd
dZ  ZS )
BarkConfiga  
    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(
    ...     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)r3   r;   r?   codec_configNr   r3   r;   r?   rG   c                    s  |d u rt  }td nt|trt di |}|d u r&t }td nt|tr2tdi |}|d u r?t }td nt|trKtdi |}|d u rZtd  }td nt|trn|dd}t| di |}|| _	|| _
|| _|| _|| _t jdi | d S )NzW`semantic_config` is `None`. Initializing the `BarkSemanticConfig` with default values.z]`coarse_acoustics_config` is `None`. Initializing the `BarkCoarseConfig` with default values.zY`fine_acoustics_config` is `None`. Initializing the `BarkFineConfig` with default values.encodeczN`codec_config` is `None`. Initializing the `codec_config` with default values.r5   r   )r-   loggerinfo
isinstancedictr8   r<   r   getr3   r;   r?   rG   r   r    r!   )r"   r3   r;   r?   rG   r   r#   codec_model_typer$   r   r&   r!      s:   	




zBarkConfig.__init__)NNNNr   )r'   r(   r)   __doc__r5   r-   r8   r<   r   sub_configsrL   r!   r,   r   r   r$   r&   rE      s,    4	rE   )r8   rE   r<   r-   N)rO   configuration_utilsr   utilsr   r   autor   r   
get_loggerr'   rI   #BARK_SUBMODELCONFIG_START_DOCSTRINGr   formatr-   r8   r<   rE   __all__r   r   r   r&   <module>   s0   
&&k