codingutf8 2023 the huggingface inc team licensed under the apache license version 2 0 the license you may not use this file except in compliance with the license you may obtain a copy of the license at http www apache orglicenseslicense2 0 unless required by applicable law or agreed to in writing software distributed under the license is distributed on an as is basis without warranties or conditions of any kind either express or implied see the license for the specific language governing permissions and limitations under the license clvp model configuration import os from typing import typechecking union if typechecking pass from configurationutils import pretrainedconfig from utils import logging logger logging getloggername clvppretrainedconfigarchivemap susnatoclvpdev https huggingface cosusnatoclvpdevresolvemainconfig json class clvpencoderconfigpretrainedconfig r this is the configuration class to store the configuration of a clvpencoder it is used to instantiate a clvp text or clvp speech encoder according to the specified arguments instantiating a configuration with the defaults will yield a similar configuration to that of the encoder of the clvp susnatoclvpdevhttps huggingface cosusnatoclvpdev architecture configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information args vocabsize int optional defaults to 256 vocabulary size of the clvp encoder model hiddensize int optional defaults to 768 dimensionality of the encoder layers and the pooler layer intermediatesize int optional defaults to 1536 dimensionality of the intermediate i e feedforward layer in the transformer encoder projectiondim int optional defaults to 768 dimensionality of the projection vector numhiddenlayers int optional defaults to 20 number of hidden layers in the transformer encoder numattentionheads int optional defaults to 12 number of attention heads for each attention layer in the transformer encoder hiddenact str or function optional defaults to gelu the nonlinear activation function function or string in the encoder and pooler if string gelu relu selu and gelunew quickgelu are supported layernormeps float optional defaults to 1e05 the epsilon used by the layer normalization layers attentiondropout float optional defaults to 0 1 the dropout ratio for the attention probabilities dropout float optional defaults to 0 1 the dropout ratio for the feedforward layers in clvpencodermlp userotaryembedding bool optional defaults to true whether to use rotaryembedding or not useattentionbias bool optional defaults to false whether to use bias in query key and value layers during self attention summarytype str optional defaults to mean what strategy to use to get pooleroutput from the lasthiddenstate last first mean and clsindex are supported initializerfactor float optional defaults to 1 0 a factor for initializing all weight matrices should be kept to 1 0 used internally for initialization testing bostokenid int optional defaults to 255 beginning of sequence token id eostokenid int optional defaults to 0 end of sequence token id example python from transformers import clvpencoderconfig clvpencoder initializing a clvpencoderconfig with susnatoclvpdev style configuration encoderconfiguration clvpencoderconfig initializing a clvpencoder with random weights from the susnatoclvpdev style configuration model clvpencoderencoderconfiguration accessing the model configuration configuration model config modeltype clvpencoder def init self vocabsize256 hiddensize768 intermediatesize1536 projectiondim768 numhiddenlayers20 numattentionheads12 hiddenactgelu layernormeps1e5 attentiondropout0 1 dropout0 1 userotaryembeddingtrue useattentionbiasfalse summarytypemean initializerfactor1 0 bostokenid255 eostokenid0 kwargs self vocabsize vocabsize self hiddensize hiddensize self intermediatesize intermediatesize self projectiondim projectiondim self numhiddenlayers numhiddenlayers self numattentionheads numattentionheads self layernormeps layernormeps self hiddenact hiddenact self initializerfactor initializerfactor self attentiondropout attentiondropout self dropout dropout self userotaryembedding userotaryembedding self useattentionbias useattentionbias self summarytype summarytype self bostokenid bostokenid self eostokenid eostokenid super initbostokenidbostokenid eostokenideostokenid kwargs classmethod def frompretrained cls pretrainedmodelnameorpath unionstr os pathlike configtype str textconfig kwargs pretrainedconfig cls settokeninkwargskwargs configdict kwargs cls getconfigdictpretrainedmodelnameorpath kwargs make sure to have the configtype be either textconfig or speechconfig this is to make sure that we can load only text or speech configs from the nested clvpconfig if configtype not in textconfig speechconfig raise valueerror fwe can only load either textconfig or speechconfig but you are trying to load fconfigtype get the text config dict if we are loading from clvpconfig if configdict getmodeltype clvp configdict configdictconfigtype if modeltype in configdict and hasattrcls modeltype and configdictmodeltype cls modeltype logger warning fyou are using a model of type configdict modeltype to instantiate a model of type fcls modeltype this is not supported for all configurations of models and can yield errors return cls fromdictconfigdict kwargs class clvpdecoderconfigpretrainedconfig r this is the configuration class to store the configuration of a clvpdecoder it is used to instantiate a clvp decoder 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 decoder part of the clvp susnatoclvpdevhttps huggingface cosusnatoclvpdev architecture configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information the architecture is similar to gpt2 args vocabsize int optional defaults to 8194 vocabulary size of the model maxpositionembeddings int optional defaults to 608 the maximum sequence length of mel tokens that this model might ever be used with similar to npositions in gpt2config maxtexttokens int optional defaults to 404 the maximum sequence length of text tokens that this model might ever be used with similar to npositions in gpt2config hiddensize int optional defaults to 1024 dimensionality of the embeddings and hidden states numhiddenlayers int optional defaults to 30 number of hidden layers in the transformer encoder numattentionheads int optional defaults to 16 number of attention heads for each attention layer in the transformer encoder ninner int optional dimensionality of the inner feedforward layers none will set it to 4 times hiddensize nummelattnblocks int optional defaults to 6 denotes the number of self attention layers in clvpconditioningencoder activationfunction str optional defaults to gelunew activation function to be selected in the list relu silu gelu tanh gelunew residpdrop float optional defaults to 0 1 the dropout probability for all fully connected layers in the embeddings encoder and pooler embdpdrop float optional defaults to 0 1 the dropout ratio for the embeddings attentiondropout float optional defaults to 0 1 the dropout ratio for the attention layernormepsilon float optional defaults to 1e05 the epsilon to use in the layer normalization layers initializerrange float optional defaults to 0 02 the standard deviation of the truncatednormalinitializer for initializing all weight matrices summarytype string optional defaults to clsindex argument used when doing sequence summary has to be one of the following options last take the last token hidden state like xlnet first take the first token hidden state like bert mean take the mean of all tokens hidden states clsindex supply a tensor of classification token position like gptgpt2 attn not implemented now use multihead attention summaryuseproj bool optional defaults to true whether or not to add a projection after the vector extraction summaryactivation str optional pass tanh for a tanh activation to the output any other value will result in no activation summaryprojtolabels bool optional defaults to true whether the projection outputs should have config numlabels or config hiddensize classes summaryfirstdropout float optional defaults to 0 1 the dropout ratio to be used after the projection and activation usecache bool optional defaults to true whether or not the model should return the last keyvalues attentions not used by all models bostokenid int optional defaults to 8192 beginning of sequence token id used at the start of the generation eostokenid int optional defaults to 8193 end of sequence token id used in the method clvpmodelforconditionalgeneration fixspeechdecoderoutput to correct decoder outputs featuresize int optional defaults to 80 the feature dimension of the extracted mel features this value is used in clvpconditioningencoder useattentionbias bool optional defaults to true whether to use bias in query key and value layers during self attention initializerfactor float optional defaults to 1 0 a factor for initializing all weight matrices should be kept to 1 0 used internally for initialization testing decoderfixingcodes list optional defaults to 83 45 45 248 these values are used in the method fixspeechdecoderoutput to fix decoder generated outputs example python from transformers import clvpdecoderconfig clvpdecoder initializing a clvpdecoderconfig with susnatoclvpdev style configuration decoderconfiguration clvpdecoderconfig initializing a clvpdecoder with random weights from the susnatoclvpdev style configuration model clvpdecoderdecoderconfiguration accessing the model configuration configuration model config modeltype clvpdecoder def init self vocabsize8194 maxpositionembeddings608 maxtexttokens404 hiddensize1024 numhiddenlayers30 numattentionheads16 ninnernone nummelattnblocks6 activationfunctiongelunew residpdrop0 1 embdpdrop0 1 attentiondropout0 1 layernormepsilon1e5 initializerrange0 02 summarytypeclsindex summaryuseprojtrue summaryactivationnone summaryprojtolabelstrue summaryfirstdropout0 1 usecachetrue bostokenid8192 eostokenid8193 featuresize80 useattentionbiastrue initializerfactor1 0 decoderfixingcodes83 45 45 248 kwargs self vocabsize vocabsize self maxpositionembeddings maxpositionembeddings self maxtexttokens maxtexttokens self hiddensize hiddensize self numhiddenlayers numhiddenlayers self numattentionheads numattentionheads self ninner ninner self nummelattnblocks nummelattnblocks self activationfunction activationfunction self residpdrop residpdrop self embdpdrop embdpdrop self attentiondropout attentiondropout self layernormepsilon layernormepsilon self initializerrange initializerrange self summarytype summarytype self summaryuseproj summaryuseproj self summaryactivation summaryactivation self summaryfirstdropout summaryfirstdropout self summaryprojtolabels summaryprojtolabels self usecache usecache self featuresize featuresize self useattentionbias useattentionbias self initializerfactor initializerfactor self decoderfixingcodes decoderfixingcodes self bostokenid bostokenid self eostokenid eostokenid super initbostokenidbostokenid eostokenideostokenid kwargs classmethod def frompretrainedcls pretrainedmodelnameorpath unionstr os pathlike kwargs pretrainedconfig cls settokeninkwargskwargs configdict kwargs cls getconfigdictpretrainedmodelnameorpath kwargs get the speech config dict if we are loading from clvpconfig if configdict getmodeltype clvp configdict configdictdecoderconfig if modeltype in configdict and hasattrcls modeltype and configdictmodeltype cls modeltype logger warning fyou are using a model of type configdict modeltype to instantiate a model of type fcls modeltype this is not supported for all configurations of models and can yield errors return cls fromdictconfigdict kwargs class clvpconfigpretrainedconfig r clvpconfig is the configuration class to store the configuration of a clvpmodelforconditionalgeneration it is used to instantiate a clvp model according to the specified arguments defining the text model speech model and decoder model configs instantiating a configuration with the defaults will yield a similar configuration to that of the clvp susnatoclvpdevhttps huggingface cosusnatoclvpdev architecture configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information args textconfig dict optional dictionary of configuration options used to initialize the clvp text encoder speechconfig dict optional dictionary of configuration options used to initialize clvp speech encoder decoderconfig dict optional dictionary of configuration options used to initialize clvpdecoderconfig projectiondim int optional defaults to 768 dimentionality of text and speech projection layers logitscaleinitvalue float optional defaults to 2 6592 the inital value of the logitscale paramter default is used as per the original clvp implementation initializerfactor float optional defaults to 1 0 a factor for initializing all weight matrices should be kept to 1 0 used internally for initialization testing kwargs optional dictionary of keyword arguments example python from transformers import clvpconfig clvpmodelforconditionalgeneration initializing a clvpconfig with susnatoclvpdev style configuration configuration clvpconfig initializing a clvpmodelforconditionalgeneration with random weights from the susnatoclvpdev style configuration model clvpmodelforconditionalgenerationconfiguration accessing the model configuration configuration model config we can also initialize a clvpconfig from a clvptextconfig clvpspeechconfig and a clvpautoregressiveconfig from transformers import clvpencoderconfig clvpdecoderconfig initializing a clvp text clvp speech and clvp decoder configuration configtext clvpencoderconfig configspeech clvpencoderconfig decoderconfig clvpdecoderconfig config clvpconfig fromsubmodelconfigsconfigtext configspeech decoderconfig modeltype clvp iscomposition true def init self textconfignone speechconfignone decoderconfignone projectiondim768 logitscaleinitvalue2 6592 initializerfactor1 0 kwargs super initkwargs if textconfig is none textconfig logger infotextconfig is none initializing the clvpencoderconfig with default values if speechconfig is none speechconfig logger infospeechconfig is none initializing the clvpencoderconfig with default values if decoderconfig is none decoderconfig logger infodecoderconfig is none initializing the clvpdecoderconfig with default values self textconfig clvpencoderconfigtextconfig self speechconfig clvpencoderconfigspeechconfig self decoderconfig clvpdecoderconfigdecoderconfig self projectiondim projectiondim self logitscaleinitvalue logitscaleinitvalue self initializerfactor initializerfactor classmethod def fromsubmodelconfigs cls textconfig clvpencoderconfig speechconfig clvpencoderconfig decoderconfig clvpdecoderconfig kwargs r instantiate a clvpconfig or a derived class from clvp text model configuration clvp speech model configuration and clvp decoder model configuration args textconfig clvpencoderconfig text model configuration of type clvpencoderconfig speechconfig clvpencoderconfig speech model configuration of type clvpencoderconfig decoderconfig clvpdecoderconfig decoder model configuration of type clvpdecoderconfig returns clvpconfig an instance of a configuration object coding utf 8 2023 the huggingface inc team licensed under the apache license version 2 0 the license you may not use this file except in compliance with the license you may obtain a copy of the license at http www apache org licenses license 2 0 unless required by applicable law or agreed to in writing software distributed under the license is distributed on an as is basis without warranties or conditions of any kind either express or implied see the license for the specific language governing permissions and limitations under the license clvp model configuration this is the configuration class to store the configuration of a clvpencoder it is used to instantiate a clvp text or clvp speech encoder according to the specified arguments instantiating a configuration with the defaults will yield a similar configuration to that of the encoder of the clvp susnato clvp_dev https huggingface co susnato clvp_dev architecture configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information args vocab_size int optional defaults to 256 vocabulary size of the clvp encoder model hidden_size int optional defaults to 768 dimensionality of the encoder layers and the pooler layer intermediate_size int optional defaults to 1536 dimensionality of the intermediate i e feed forward layer in the transformer encoder projection_dim int optional defaults to 768 dimensionality of the projection vector num_hidden_layers int optional defaults to 20 number of hidden layers in the transformer encoder num_attention_heads int optional defaults to 12 number of attention heads for each attention layer in the transformer encoder hidden_act str or function optional defaults to gelu the non linear activation function function or string in the encoder and pooler if string gelu relu selu and gelu_new quick_gelu are supported layer_norm_eps float optional defaults to 1e 05 the epsilon used by the layer normalization layers attention_dropout float optional defaults to 0 1 the dropout ratio for the attention probabilities dropout float optional defaults to 0 1 the dropout ratio for the feed forward layers in clvpencodermlp use_rotary_embedding bool optional defaults to true whether to use rotary_embedding or not use_attention_bias bool optional defaults to false whether to use bias in query key and value layers during self attention summary_type str optional defaults to mean what strategy to use to get pooler_output from the last_hidden_state last first mean and cls_index are supported initializer_factor float optional defaults to 1 0 a factor for initializing all weight matrices should be kept to 1 0 used internally for initialization testing bos_token_id int optional defaults to 255 beginning of sequence token id eos_token_id int optional defaults to 0 end of sequence token id example python from transformers import clvpencoderconfig clvpencoder initializing a clvpencoderconfig with susnato clvp_dev style configuration encoder_configuration clvpencoderconfig initializing a clvpencoder with random weights from the susnato clvp_dev style configuration model clvpencoder encoder_configuration accessing the model configuration configuration model config make sure to have the config_type be either text_config or speech_config this is to make sure that we can load only text or speech configs from the nested clvpconfig get the text config dict if we are loading from clvpconfig this is the configuration class to store the configuration of a clvpdecoder it is used to instantiate a clvp decoder 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 decoder part of the clvp susnato clvp_dev https huggingface co susnato clvp_dev architecture configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information the architecture is similar to gpt2 args vocab_size int optional defaults to 8194 vocabulary size of the model max_position_embeddings int optional defaults to 608 the maximum sequence length of mel tokens that this model might ever be used with similar to n_positions in gpt2config max_text_tokens int optional defaults to 404 the maximum sequence length of text tokens that this model might ever be used with similar to n_positions in gpt2config hidden_size int optional defaults to 1024 dimensionality of the embeddings and hidden states num_hidden_layers int optional defaults to 30 number of hidden layers in the transformer encoder num_attention_heads int optional defaults to 16 number of attention heads for each attention layer in the transformer encoder n_inner int optional dimensionality of the inner feed forward layers none will set it to 4 times hidden_size num_mel_attn_blocks int optional defaults to 6 denotes the number of self attention layers in clvpconditioningencoder activation_function str optional defaults to gelu_new activation function to be selected in the list relu silu gelu tanh gelu_new resid_pdrop float optional defaults to 0 1 the dropout probability for all fully connected layers in the embeddings encoder and pooler embd_pdrop float optional defaults to 0 1 the dropout ratio for the embeddings attention_dropout float optional defaults to 0 1 the dropout ratio for the attention layer_norm_epsilon float optional defaults to 1e 05 the epsilon to use in the layer normalization layers initializer_range float optional defaults to 0 02 the standard deviation of the truncated_normal_initializer for initializing all weight matrices summary_type string optional defaults to cls_index argument used when doing sequence summary has to be one of the following options last take the last token hidden state like xlnet first take the first token hidden state like bert mean take the mean of all tokens hidden states cls_index supply a tensor of classification token position like gpt gpt 2 attn not implemented now use multi head attention summary_use_proj bool optional defaults to true whether or not to add a projection after the vector extraction summary_activation str optional pass tanh for a tanh activation to the output any other value will result in no activation summary_proj_to_labels bool optional defaults to true whether the projection outputs should have config num_labels or config hidden_size classes summary_first_dropout float optional defaults to 0 1 the dropout ratio to be used after the projection and activation use_cache bool optional defaults to true whether or not the model should return the last key values attentions not used by all models bos_token_id int optional defaults to 8192 beginning of sequence token id used at the start of the generation eos_token_id int optional defaults to 8193 end of sequence token id used in the method clvpmodelforconditionalgeneration fix_speech_decoder_output to correct decoder outputs feature_size int optional defaults to 80 the feature dimension of the extracted mel features this value is used in clvpconditioningencoder use_attention_bias bool optional defaults to true whether to use bias in query key and value layers during self attention initializer_factor float optional defaults to 1 0 a factor for initializing all weight matrices should be kept to 1 0 used internally for initialization testing decoder_fixing_codes list optional defaults to 83 45 45 248 these values are used in the method fix_speech_decoder_output to fix decoder generated outputs example python from transformers import clvpdecoderconfig clvpdecoder initializing a clvpdecoderconfig with susnato clvp_dev style configuration decoder_configuration clvpdecoderconfig initializing a clvpdecoder with random weights from the susnato clvp_dev style configuration model clvpdecoder decoder_configuration accessing the model configuration configuration model config get the speech config dict if we are loading from clvpconfig clvpconfig is the configuration class to store the configuration of a clvpmodelforconditionalgeneration it is used to instantiate a clvp model according to the specified arguments defining the text model speech model and decoder model configs instantiating a configuration with the defaults will yield a similar configuration to that of the clvp susnato clvp_dev https huggingface co susnato clvp_dev architecture configuration objects inherit from pretrainedconfig and can be used to control the model outputs read the documentation from pretrainedconfig for more information args text_config dict optional dictionary of configuration options used to initialize the clvp text encoder speech_config dict optional dictionary of configuration options used to initialize clvp speech encoder decoder_config dict optional dictionary of configuration options used to initialize clvpdecoderconfig projection_dim int optional defaults to 768 dimentionality of text and speech projection layers logit_scale_init_value float optional defaults to 2 6592 the inital value of the logit_scale paramter default is used as per the original clvp implementation initializer_factor float optional defaults to 1 0 a factor for initializing all weight matrices should be kept to 1 0 used internally for initialization testing kwargs optional dictionary of keyword arguments example python from transformers import clvpconfig clvpmodelforconditionalgeneration initializing a clvpconfig with susnato clvp_dev style configuration configuration clvpconfig initializing a clvpmodelforconditionalgeneration with random weights from the susnato clvp_dev style configuration model clvpmodelforconditionalgeneration configuration accessing the model configuration configuration model config we can also initialize a clvpconfig from a clvptextconfig clvpspeechconfig and a clvpautoregressiveconfig from transformers import clvpencoderconfig clvpdecoderconfig initializing a clvp text clvp speech and clvp decoder configuration config_text clvpencoderconfig config_speech clvpencoderconfig decoder_config clvpdecoderconfig config clvpconfig from_sub_model_configs config_text config_speech decoder_config instantiate a clvpconfig or a derived class from clvp text model configuration clvp speech model configuration and clvp decoder model configuration args text_config clvpencoderconfig text model configuration of type clvpencoderconfig speech_config clvpencoderconfig speech model configuration of type clvpencoderconfig decoder_config clvpdecoderconfig decoder model configuration of type clvpdecoderconfig returns clvpconfig an instance of a configuration object
import os
from typing import TYPE_CHECKING, Union


if TYPE_CHECKING:
    pass

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


logger = logging.get_logger(__name__)

CLVP_PRETRAINED_CONFIG_ARCHIVE_MAP = {
    "susnato/clvp_dev": "https://huggingface.co/susnato/clvp_dev/resolve/main/config.json",
}


class ClvpEncoderConfig(PretrainedConfig):
    r

    model_type = "clvp_encoder"

    def __init__(
        self,
        vocab_size=256,
        hidden_size=768,
        intermediate_size=1536,
        projection_dim=768,
        num_hidden_layers=20,
        num_attention_heads=12,
        hidden_act="gelu",
        layer_norm_eps=1e-5,
        attention_dropout=0.1,
        dropout=0.1,
        use_rotary_embedding=True,
        use_attention_bias=False,
        summary_type="mean",
        initializer_factor=1.0,
        bos_token_id=255,
        eos_token_id=0,
        **kwargs,
    ):
        self.vocab_size = vocab_size
        self.hidden_size = hidden_size
        self.intermediate_size = intermediate_size
        self.projection_dim = projection_dim
        self.num_hidden_layers = num_hidden_layers
        self.num_attention_heads = num_attention_heads
        self.layer_norm_eps = layer_norm_eps
        self.hidden_act = hidden_act
        self.initializer_factor = initializer_factor
        self.attention_dropout = attention_dropout
        self.dropout = dropout
        self.use_rotary_embedding = use_rotary_embedding
        self.use_attention_bias = use_attention_bias
        self.summary_type = summary_type
        self.bos_token_id = bos_token_id
        self.eos_token_id = eos_token_id

        super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)

    @classmethod
    def from_pretrained(
        cls, pretrained_model_name_or_path: Union[str, os.PathLike], config_type: str = "text_config", **kwargs
    ) -> "PretrainedConfig":
        cls._set_token_in_kwargs(kwargs)

        config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)

        
        
        if config_type not in ["text_config", "speech_config"]:
            raise ValueError(
                f"We can only load either 'text_config' or 'speech_config' but you are trying to load" f"{config_type}"
            )

        
        if config_dict.get("model_type") == "clvp":
            config_dict = config_dict[config_type]

        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(config_dict, **kwargs)


class ClvpDecoderConfig(PretrainedConfig):
    r

    model_type = "clvp_decoder"

    def __init__(
        self,
        vocab_size=8194,
        max_position_embeddings=608,
        max_text_tokens=404,
        hidden_size=1024,
        num_hidden_layers=30,
        num_attention_heads=16,
        n_inner=None,
        num_mel_attn_blocks=6,
        activation_function="gelu_new",
        resid_pdrop=0.1,
        embd_pdrop=0.1,
        attention_dropout=0.1,
        layer_norm_epsilon=1e-5,
        initializer_range=0.02,
        summary_type="cls_index",
        summary_use_proj=True,
        summary_activation=None,
        summary_proj_to_labels=True,
        summary_first_dropout=0.1,
        use_cache=True,
        bos_token_id=8192,
        eos_token_id=8193,
        feature_size=80,
        use_attention_bias=True,
        initializer_factor=1.0,
        decoder_fixing_codes=[83, 45, 45, 248],
        **kwargs,
    ):
        self.vocab_size = vocab_size
        self.max_position_embeddings = max_position_embeddings
        self.max_text_tokens = max_text_tokens
        self.hidden_size = hidden_size
        self.num_hidden_layers = num_hidden_layers
        self.num_attention_heads = num_attention_heads
        self.n_inner = n_inner
        self.num_mel_attn_blocks = num_mel_attn_blocks
        self.activation_function = activation_function
        self.resid_pdrop = resid_pdrop
        self.embd_pdrop = embd_pdrop
        self.attention_dropout = attention_dropout
        self.layer_norm_epsilon = layer_norm_epsilon
        self.initializer_range = initializer_range
        self.summary_type = summary_type
        self.summary_use_proj = summary_use_proj
        self.summary_activation = summary_activation
        self.summary_first_dropout = summary_first_dropout
        self.summary_proj_to_labels = summary_proj_to_labels
        self.use_cache = use_cache
        self.feature_size = feature_size
        self.use_attention_bias = use_attention_bias
        self.initializer_factor = initializer_factor
        self.decoder_fixing_codes = decoder_fixing_codes

        self.bos_token_id = bos_token_id
        self.eos_token_id = eos_token_id

        super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)

    @classmethod
    def from_pretrained(cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs) -> "PretrainedConfig":
        cls._set_token_in_kwargs(kwargs)

        config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)

        
        if config_dict.get("model_type") == "clvp":
            config_dict = config_dict["decoder_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(config_dict, **kwargs)


class ClvpConfig(PretrainedConfig):
    r

    model_type = "clvp"
    is_composition = True

    def __init__(
        self,
        text_config=None,
        speech_config=None,
        decoder_config=None,
        projection_dim=768,
        logit_scale_init_value=2.6592,
        initializer_factor=1.0,
        **kwargs,
    ):
        super().__init__(**kwargs)

        if text_config is None:
            text_config = {}
            logger.info("`text_config` is `None`. Initializing the `ClvpEncoderConfig` with default values.")

        if speech_config is None:
            speech_config = {}
            logger.info("`speech_config` is `None`. initializing the `ClvpEncoderConfig` with default values.")

        if decoder_config is None:
            decoder_config = {}
            logger.info("`decoder_config` is `None`. initializing the `ClvpDecoderConfig` with default values.")

        self.text_config = ClvpEncoderConfig(**text_config)
        self.speech_config = ClvpEncoderConfig(**speech_config)
        self.decoder_config = ClvpDecoderConfig(**decoder_config)

        self.projection_dim = projection_dim
        self.logit_scale_init_value = logit_scale_init_value
        self.initializer_factor = initializer_factor

    @classmethod
    def from_sub_model_configs(
        cls,
        text_config: ClvpEncoderConfig,
        speech_config: ClvpEncoderConfig,
        decoder_config: ClvpDecoderConfig,
        **kwargs,
    ):
        r

        return cls(
            text_config=text_config.to_dict(),
            speech_config=speech_config.to_dict(),
            decoder_config=decoder_config.to_dict(),
            **kwargs,
        )