§
    9²¸j*:  ã                   óº   — d Z ddlZddlmZ ddlmZ  ej        e¦  «        Z G d„ de¦  «        Z	 G d„ d	e¦  «        Z
 G d
„ de¦  «        Z G d„ de¦  «        ZdS )z#BARK model generation configurationé    Né   )ÚGenerationConfig)Úloggingc                   óD   ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚBarkSemanticGenerationConfigÚsemanticé'  Té   Fç      ð?é@'  é;ú é?ú é   ç33333óH@Nc                 ó¾   •—  t          ¦   «         j        d||	|||||||dœ	|¤Ž |
| _        || _        || _        || _        || _        || _        || _        || _	        dS )a  Class that holds a generation configuration for [`BarkSemanticModel`].

        This configuration inherit from [`GenerationConfig`] and can be used to control the model generation. Read the
        documentation from [`GenerationConfig`] for more information.

        Args:
            eos_token_id (`int`, *optional*, defaults to 10_000):
                The id of the *end-of-sequence* token.
            renormalize_logits (`bool`, *optional*, defaults to `True`):
                Whether to renormalize the logits after applying all the logits processors (including the
                custom ones). It's highly recommended to set this flag to `True` as the search algorithms suppose the
                score logits are normalized but some logit processors break the normalization.
            max_new_tokens (`int`, *optional*, defaults to 768):
                The maximum numbers of tokens to generate, ignoring the number of tokens in the prompt.
            output_scores (`bool`, *optional*, defaults to `False`):
                Whether or not to return the prediction scores. See `scores` under returned tensors for more details.
            return_dict_in_generate (`bool`, *optional*, defaults to `False`):
                Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
            output_hidden_states (`bool`, *optional*, defaults to `False`):
                Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors
                for more details.
            output_attentions (`bool`, *optional*, defaults to `False`):
                Whether or not to return the attentions tensors of all attention layers. See `attentions` under
                returned tensors for more details.
            temperature (`float`, *optional*, defaults to 1.0):
                The value used to modulate the next token probabilities.
            do_sample (`bool`, *optional*, defaults to `False`):
                Whether or not to use sampling ; use greedy decoding otherwise.
            text_encoding_offset (`int`, *optional*, defaults to 10_048):
                Text encoding offset.
            text_pad_token (`int`, *optional*, defaults to 129_595):
                Text pad token.
            semantic_infer_token (`int`, *optional*, defaults to 129_599):
                Semantic infer token.
            semantic_vocab_size (`int`, *optional*, defaults to 10_000):
                Semantic vocab size.
            max_input_semantic_length (`int`, *optional*, defaults to 256):
                Max length of semantic input vector.
            semantic_rate_hz (`float`, *optional*, defaults to 49.9):
                Semantic rate in Hertz.
            min_eos_p (`float`, *optional*):
                Minimum threshold of the probability of the EOS token for it to be sampled. This is an early stopping
                strategy to mitigate potential unwanted generations at the end of a prompt. The original implementation
                suggests a default value of 0.2.
        )	ÚtemperatureÚ	do_sampleÚeos_token_idÚrenormalize_logitsÚmax_new_tokensÚoutput_scoresÚreturn_dict_in_generateÚoutput_hidden_statesÚoutput_attentionsN© )
ÚsuperÚ__init__Útext_encoding_offsetÚtext_pad_tokenÚsemantic_pad_tokenÚsemantic_infer_tokenÚsemantic_vocab_sizeÚmax_input_semantic_lengthÚsemantic_rate_hzÚ	min_eos_p)Úselfr   r   r   r   r   r   r   r   r   r   r   r!   r"   r#   r$   r%   ÚkwargsÚ	__class__s                     €ú†/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/transformers/models/bark/generation_configuration_bark.pyr   z%BarkSemanticGenerationConfig.__init__   s•   ø€ ðB 	�‰ŒÔð 	
Ø#ØØ%Ø1Ø)Ø'Ø$;Ø!5Ø/ð	
ð 	
ð ð	
ð 	
ð 	
ð %9ˆÔ!Ø,ˆÔØ".ˆÔØ$8ˆÔ!Ø#6ˆÔ Ø)BˆÔ&Ø 0ˆÔØ"ˆŒˆˆó    )r	   Tr
   FFFFr   Fr   r   r   r	   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú
model_typer   Ú__classcell__©r(   s   @r)   r   r      s~   ø€ € € € € Ø€Jð ØØØØ %Ø"ØØØØ#ØØ$Ø"Ø"%ØØð#U#ð U#ð U#ð U#ð U#ð U#ð U#ð U#ð U#ð U#r*   r   c                   óJ   ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddedefˆ fd„Zˆ xZS )ÚBarkCoarseGenerationConfigÚcoarse_acousticsTFr   é/  éK   é   é/  r   év  é<   Úmax_coarse_historyÚsliding_window_lenc                 ó¬   •—  t          ¦   «         j        d|||||||dœ|¤Ž || _        |	| _        |
| _        || _        || _        || _        || _        dS )as
  Class that holds a generation configuration for [`BarkCoarseModel`].

        This configuration inherit from [`GenerationConfig`] and can be used to control the model generation. Read the
        documentation from [`GenerationConfig`] for more information.

        Args:
            renormalize_logits (`bool`, *optional*, defaults to `True`):
                Whether to renormalize the logits after applying all the logits processors (including the
                custom ones). It's highly recommended to set this flag to `True` as the search algorithms suppose the
                score logits are normalized but some logit processors break the normalization.
            output_scores (`bool`, *optional*, defaults to `False`):
                Whether or not to return the prediction scores. See `scores` under returned tensors for more details.
            return_dict_in_generate (`bool`, *optional*, defaults to `False`):
                Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
            output_hidden_states (`bool`, *optional*, defaults to `False`):
                Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors
                for more details.
            output_attentions (`bool`, *optional*, defaults to `False`):
                Whether or not to return the attentions tensors of all attention layers. See `attentions` under
                returned tensors for more details.
            temperature (`float`, *optional*, defaults to 1.0):
                The value used to modulate the next token probabilities.
            do_sample (`bool`, *optional*, defaults to `False`):
                Whether or not to use sampling ; use greedy decoding otherwise.
            coarse_semantic_pad_token (`int`, *optional*, defaults to 12_048):
                Coarse semantic pad token.
            coarse_rate_hz (`int`, *optional*, defaults to 75):
                Coarse rate in Hertz.
            n_coarse_codebooks (`int`, *optional*, defaults to 2):
                Number of coarse codebooks.
            coarse_infer_token (`int`, *optional*, defaults to 12_050):
                Coarse infer token.
            max_coarse_input_length (`int`, *optional*, defaults to 256):
                Max length of input coarse vector.
            max_coarse_history (`int`, *optional*, defaults to 630):
                Max length of the output of the coarse acoustics model used in the fine generation step.
            sliding_window_len (`int`, *optional*, defaults to 60):
                The coarse generation step uses a sliding window to generate raw audio.
        )r   r   r   r   r   r   r   Nr   )	r   r   Úcoarse_semantic_pad_tokenÚcoarse_rate_hzÚn_coarse_codebooksÚcoarse_infer_tokenÚmax_coarse_input_lengthr:   r;   )r&   r   r   r   r   r   r   r   r=   r>   r?   r@   rA   r:   r;   r'   r(   s                   €r)   r   z#BarkCoarseGenerationConfig.__init__w   s‹   ø€ ðr 	�‰ŒÔð 		
Ø#ØØ1Ø'Ø$;Ø!5Ø/ð		
ð 		
ð ð		
ð 		
ð 		
ð *CˆÔ&Ø,ˆÔØ"4ˆÔØ"4ˆÔØ'>ˆÔ$Ø"4ˆÔØ"4ˆÔÐÐr*   )TFFFFr   Fr4   r5   r6   r7   r   r8   r9   )r+   r,   r-   r.   Úintr   r/   r0   s   @r)   r2   r2   t   s”   ø€ € € € € Ø#€Jð  ØØ %Ø"ØØØØ"(ØØØ!Ø #Ø"%Ø"$ðJ5ð J5ð  ðJ5ð  ðJ5ð J5ð J5ð J5ð J5ð J5ð J5ð J5ð J5ð J5r*   r2   c                   ó2   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zd„ Zˆ xZS )	ÚBarkFineGenerationConfigÚfine_acousticsr   é   é   é   c                 óv   •— t          ¦   «                              |¬¦  «         || _        || _        || _        dS )aª  Class that holds a generation configuration for [`BarkFineModel`].

        [`BarkFineModel`] is an autoencoder model, so should not usually be used for generation. However, under the
        hood, it uses `temperature` when used by [`BarkModel`]

        This configuration inherit from [`GenerationConfig`] and can be used to control the model generation. Read the
        documentation from [`GenerationConfig`] for more information.

        Args:
            temperature (`float`, *optional*):
                The value used to modulate the next token probabilities.
            max_fine_history_length (`int`, *optional*, defaults to 512):
                Max length of the fine history vector.
            max_fine_input_length (`int`, *optional*, defaults to 1024):
                Max length of fine input vector.
            n_fine_codebooks (`int`, *optional*, defaults to 8):
                Number of codebooks used.
        )r   N)r   r   Úmax_fine_history_lengthÚmax_fine_input_lengthÚn_fine_codebooks)r&   r   rJ   rK   rL   r'   r(   s         €r)   r   z!BarkFineGenerationConfig.__init__Ç   s>   ø€ õ4 	‰Œ×Ò [ÐÑ1Ô1Ð1à'>ˆÔ$Ø%:ˆÔ"Ø 0ˆÔÐÐr*   c                 ó   — dS )zŒ
        Overrides GenerationConfig.validate because BarkFineGenerationConfig don't use any parameters outside
        temperature.
        Nr   )r&   r'   s     r)   Úvalidatez!BarkFineGenerationConfig.validateç   s   € € € r*   )r   rF   rG   rH   )r+   r,   r-   r.   r   rN   r/   r0   s   @r)   rD   rD   Ä   s`   ø€ € € € € Ø!€Jð Ø #Ø"Øð1ð 1ð 1ð 1ð 1ð 1ð@ð ð ð ð ð ð r*   rD   c                   ón   — e Zd ZdZ	 	 	 	 	 ddedz  dedz  dedz  fd„Zededede	fd	„¦   «         Z
d
„ ZdS )ÚBarkGenerationConfigÚbarkNéÀ]  rG   Úsemantic_configÚcoarse_acoustics_configÚfine_acoustics_configc                 ó<  — |€i }t                                d¦  «         |€i }t                                d¦  «         |€i }t                                d¦  «         t          di |¤Ž| _        t	          di |¤Ž| _        t          di |¤Ž| _        || _        || _	        dS )a$  Class that holds a generation configuration for [`BarkModel`].

        The [`BarkModel`] does not have a `generate` method, but uses this class to generate speeches with a nested
        [`BarkGenerationConfig`] which uses [`BarkSemanticGenerationConfig`], [`BarkCoarseGenerationConfig`],
        [`BarkFineGenerationConfig`].

        This configuration inherit from [`GenerationConfig`] and can be used to control the model generation. Read the
        documentation from [`GenerationConfig`] for more information.

        Args:
            semantic_config (`Dict`, *optional*):
                Semantic generation configuration.
            coarse_acoustics_config (`Dict`, *optional*):
                Coarse generation configuration.
            fine_acoustics_config (`Dict`, *optional*):
                Fine generation configuration.
            sample_rate (`int`, *optional*, defaults to 24_000):
                Sample rate.
            codebook_size (`int`, *optional*, defaults to 1024):
                Vector length for each codebook.
        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.r   )
ÚloggerÚinfor   rS   r2   rT   rD   rU   Úsample_rateÚcodebook_size)r&   rS   rT   rU   rY   rZ   r'   s          r)   r   zBarkGenerationConfig.__init__ó   sº   € ð< Ð"Ø ˆOÝ�KŠKÐgÑhÔhÐhà"Ð*Ø&(Ð#Ý�KŠKÐmÑnÔnÐnà Ð(Ø$&Ð!Ý�KŠKÐiÑjÔjÐjå;ÐNÐN¸oÐNÐNˆÔÝ'AÐ'\Ð'\ÐD[Ð'\Ð'\ˆÔ$Ý%=Ð%VÐ%VÐ@UÐ%VÐ%VˆÔ"à&ˆÔØ*ˆÔÐÐr*   c                 ó†   —  | d|                      ¦   «         |                      ¦   «         |                      ¦   «         dœ|¤ŽS )zÚ
        Instantiate a [`BarkGenerationConfig`] (or a derived class) from bark sub-models generation configuration.

        Returns:
            [`BarkGenerationConfig`]: An instance of a configuration object
        )rS   rT   rU   r   )Úto_dict)ÚclsrS   rT   rU   r'   s        r)   Úfrom_sub_model_configsz+BarkGenerationConfig.from_sub_model_configs$  sY   € ð ˆsð 
Ø+×3Ò3Ñ5Ô5Ø$;×$CÒ$CÑ$EÔ$EØ"7×"?Ò"?Ñ"AÔ"Að
ð 
ð ð	
ð 
ð 	
r*   c                 óþ   — t          j        | j        ¦  «        }| j                             ¦   «         |d<   | j                             ¦   «         |d<   | j                             ¦   «         |d<   | j        j        |d<   |S )zñ
        Serializes this instance to a Python dictionary. Override the default [`~PreTrainedConfig.to_dict`].

        Returns:
            `dict[str, any]`: Dictionary of all the attributes that make up this configuration instance,
        rS   rT   rU   r.   )	ÚcopyÚdeepcopyÚ__dict__rS   r\   rT   rU   r(   r.   )r&   Úoutputs     r)   r\   zBarkGenerationConfig.to_dict9  sw   € õ ”˜tœ}Ñ-Ô-ˆà$(Ô$8×$@Ò$@Ñ$BÔ$BˆÐ Ñ!Ø,0Ô,H×,PÒ,PÑ,RÔ,RˆÐ(Ñ)Ø*.Ô*D×*LÒ*LÑ*NÔ*NˆÐ&Ñ'à#œ~Ô8ˆˆ|ÑØˆr*   )NNNrR   rG   )r+   r,   r-   r.   Údictr   Úclassmethodr   r2   rD   r^   r\   r   r*   r)   rP   rP   î   s·   € € € € € Ø€Jð (,Ø/3Ø-1ØØð/+ð /+à ™ð/+ð "&¨¡ð/+ð  $ d™{ð	/+ð /+ð /+ð /+ðb ð
à5ð
ð "<ð
ð  8ð	
ð 
ð 
ñ „[ð
ð(ð ð ð ð r*   rP   )Ú__doc__r`   Úgeneration.configuration_utilsr   Úutilsr   Ú
get_loggerr+   rW   r   r2   rD   rP   r   r*   r)   ú<module>rj      s!  ðð *Ð )à €€€à >Ð >Ð >Ð >Ð >Ð >Ø Ð Ð Ð Ð Ð ð 
ˆÔ	˜HÑ	%Ô	%€ðX#ð X#ð X#ð X#ð X#Ð#3ñ X#ô X#ð X#ðvM5ð M5ð M5ð M5ð M5Ð!1ñ M5ô M5ð M5ð`'ð 'ð 'ð 'ð 'Ð/ñ 'ô 'ð 'ðTYð Yð Yð Yð YÐ+ñ Yô Yð Yð Yð Yr*   