




import copy

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


__SCREAMING_SNAKE_CASE    :   Any       =logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE    :   str       ={
    """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 			A			(		_lowerCAmelCase		):
     """simple docstring"""

     _snake_case:	str     ="musicgen_decoder"
     _snake_case:	Any     =["past_key_values"]




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






class 			A			(		_lowerCAmelCase		):
     """simple docstring"""

     _snake_case:	Union[str, Any]     ="musicgen"
     _snake_case:	Optional[int]     =True




     def __init__(    self  :   List[str]	,  **A__  :   List[Any]			)				->       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'			)

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

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

           lowerCamelCase__        =				kwargs.pop('decoder'			)

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




     @classmethod
     def  __snake_case   (    cls  :   Union[str, Any]	,  A__  :   PretrainedConfig	,  A__  :   PretrainedConfig	,  A__  :   MusicgenDecoderConfig	,  **A__  :   Tuple	,  )				->       Tuple:
           return cls(
               text_encoder=text_encoder_config.to_dict()	,  audio_encoder=audio_encoder_config.to_dict()	,  decoder=decoder_config.to_dict()	,  **A__	,  )




     def  __snake_case   (    self  :   Tuple			)				->       Dict:
           lowerCamelCase__        =				copy.deepcopy(self.__dict__			)
           lowerCamelCase__        =				self.text_encoder.to_dict()
           lowerCamelCase__        =				self.audio_encoder.to_dict()
           lowerCamelCase__        =				self.decoder.to_dict()
           lowerCamelCase__        =				self.__class__.model_type
           return output





import importlib.metadata
import sys

from transformers.testing_utils import TestCasePlus
from transformers.utils.versions import require_version, require_version_core


__SCREAMING_SNAKE_CASE    :   int       =importlib.metadata.version("""numpy""")
__SCREAMING_SNAKE_CASE    :   Optional[int]       =""".""".join([str(x) for x in sys.version_info[:3]])






class 			A			(		_lowerCAmelCase		):
     """simple docstring"""

     def  __snake_case   (    self  :   List[Any]			)				->       Optional[int]:
           # lt + different version strings
           require_version_core('numpy<1000.4.5'			)
           require_version_core('numpy<1000.4'			)
           require_version_core('numpy<1000'			)

           # le
           require_version_core('numpy<=1000.4.5'			)
           require_version_core(F"""numpy<={numpy_ver}"""			)

           # eq
           require_version_core(F"""numpy=={numpy_ver}"""			)

           # ne
           require_version_core('numpy!=1000.4.5'			)

           # ge
           require_version_core('numpy>=1.0'			)
           require_version_core('numpy>=1.0.0'			)
           require_version_core(F"""numpy>={numpy_ver}"""			)

           # gt
           require_version_core('numpy>1.0.0'			)

           # mix
           require_version_core('numpy>1.0.0,<1000'			)

           # requirement w/o version
           require_version_core('numpy'			)

           # unmet requirements due to version conflict
           for req in ["numpy==1.0.0", "numpy>=1000.0.0", F"""numpy<{numpy_ver}"""]:
                 try:
                       require_version_core(A__			)
                 except ImportError as e:
                       self.assertIn(F"""{req} is required"""	,  str(A__			)			)
                       self.assertIn('but found'	,  str(A__			)			)

        # unmet requirements due to missing module
           for req in ["numpipypie>1", "numpipypie2"]:
                 try:
                       require_version_core(A__			)
                 except importlib.metadata.PackageNotFoundError as e:
                       self.assertIn(F"""The '{req}' distribution was not found and is required by this application"""	,  str(A__			)			)
                       self.assertIn('Try: pip install transformers -U'	,  str(A__			)			)

        # bogus requirements formats:
        # 1. whole thing
           for req in ["numpy??1.0.0", "numpy1.0.0"]:
                 try:
                       require_version_core(A__			)
                 except ValueError as e:
                       self.assertIn('requirement needs to be in the pip package format'	,  str(A__			)			)
        # 2. only operators
           for req in ["numpy=1.0.0", "numpy == 1.00", "numpy<>1.0.0", "numpy><1.00", "numpy>>1.0.0"]:
                 try:
                       require_version_core(A__			)
                 except ValueError as e:
                       self.assertIn('need one of '	,  str(A__			)			)




     def  __snake_case   (    self  :   str			)				->       Optional[int]:
           # matching requirement
           require_version('python>=3.6.0'			)

           # not matching requirements
           for req in ["python>9.9.9", "python<3.0.0"]:
                 try:
                       require_version_core(A__			)
                 except ImportError as e:
                       self.assertIn(F"""{req} is required"""	,  str(A__			)			)
                       self.assertIn(F"""but found python=={python_ver}"""	,  str(A__			)			)