

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


__A     						=      logging.get_logger(__name__)

__A     						=      {
    '''facebook/musicgen-small''': '''https://huggingface.co/facebook/musicgen-small/resolve/main/config.json''',
    # See all Musicgen models at https://huggingface.co/models?filter=musicgen
}



class     lowercase_       (    __lowercase	):
      UpperCamelCase_     :						Tuple		 =							"musicgen_decoder"
      UpperCamelCase_     :						Optional[int]		 =							["past_key_values"]



      def __init__(     self :							int     ,   A__ :							Any=2048     ,   A__ :							Any=2048     ,   A__ :							Any=24     ,   A__ :							str=4096     ,   A__ :							int=16     ,   A__ :							Any=0.0     ,   A__ :							Union[str, Any]=True     ,   A__ :							Dict="gelu"     ,   A__ :							Dict=1024     ,   A__ :							Dict=0.1     ,   A__ :							int=0.0     ,   A__ :							Tuple=0.0     ,   A__ :							List[Any]=0.02     ,   A__ :							str=False     ,   A__ :							int=4     ,   A__ :							Optional[Any]=2048     ,   A__ :							Optional[int]=2048     ,   A__ :							Tuple=None     ,   A__ :							str=False     ,   **A__ :							Tuple     ,   )       ->	Union[str, Any]:
        _snake_case		=				vocab_size
        _snake_case		=				max_position_embeddings
        _snake_case		=				hidden_size
        _snake_case		=				ffn_dim
        _snake_case		=				num_hidden_layers
        _snake_case		=				num_attention_heads
        _snake_case		=				dropout
        _snake_case		=				attention_dropout
        _snake_case		=				activation_dropout
        _snake_case		=				activation_function
        _snake_case		=				initializer_factor
        _snake_case		=				layerdrop
        _snake_case		=				use_cache
        _snake_case		=				scale_embedding  # scale factor will be sqrt(d_model) if True
        _snake_case		=				num_codebooks
        super().__init__(
            pad_token_id=A__     ,   bos_token_id=A__     ,   eos_token_id=A__     ,   tie_word_embeddings=A__     ,   **A__     ,   )



class     lowercase_       (    __lowercase	):
      UpperCamelCase_     :						Any		 =							"musicgen"
      UpperCamelCase_     :						Optional[int]		 =							True



      def __init__(     self :							Tuple     ,   **A__ :							Union[str, Any]						)       ->	List[str]:
        super().__init__(**A__						)
        if "text_encoder" not in kwargs or "audio_encoder" not in kwargs or "decoder" not in kwargs:
          raise ValueError('''Config has to be initialized with text_encoder, audio_encoder and decoder config'''						)

        _snake_case		=				kwargs.pop('''text_encoder'''						)
        _snake_case		=				text_encoder_config.pop('''model_type'''						)

        _snake_case		=				kwargs.pop('''audio_encoder'''						)
        _snake_case		=				audio_encoder_config.pop('''model_type'''						)

        _snake_case		=				kwargs.pop('''decoder'''						)

        _snake_case		=				AutoConfig.for_model(A__     ,   **A__						)
        _snake_case		=				AutoConfig.for_model(A__     ,   **A__						)
        _snake_case		=				MusicgenDecoderConfig(**A__						)
        _snake_case		=				True



      @classmethod
      def 		UpperCamelCase_						(     cls :							Optional[Any]     ,   A__ :							PretrainedConfig     ,   A__ :							PretrainedConfig     ,   A__ :							MusicgenDecoderConfig     ,   **A__ :							int     ,   )       ->	List[Any]:
        return cls(
            text_encoder=text_encoder_config.to_dict()     ,   audio_encoder=audio_encoder_config.to_dict()     ,   decoder=decoder_config.to_dict()     ,   **A__     ,   )







      def 		UpperCamelCase_						(     self :							Any						)       ->	List[Any]:
        _snake_case		=				copy.deepcopy(self.__dict__						)
        _snake_case		=				self.text_encoder.to_dict()
        _snake_case		=				self.audio_encoder.to_dict()
        _snake_case		=				self.decoder.to_dict()
        _snake_case		=				self.__class__.model_type
        return output




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


__A     						=      {'''configuration_hubert''': ['''HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''HubertConfig''']}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A     						=      [
     '''HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''HubertForCTC''',
     '''HubertForSequenceClassification''',
     '''HubertModel''',
     '''HubertPreTrainedModel''',
 ]


try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A     						=      [
     '''TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''TFHubertForCTC''',
     '''TFHubertModel''',
     '''TFHubertPreTrainedModel''',
 ]

if TYPE_CHECKING:
 from .configuration_hubert import HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, HubertConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_hubert import (
      HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      HubertForCTC,
      HubertForSequenceClassification,
      HubertModel,
      HubertPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_hubert import (
      TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFHubertForCTC,
      TFHubertModel,
      TFHubertPreTrainedModel,
  )


else:
 import sys

 __A     						=      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)

