






from sklearn.metrics import mean_absolute_error

import datasets


a		:	str      					=			"\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.\n         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and\n         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},\n journal={Journal of Machine Learning Research},\n volume={12},\n pages={2825--2830},\n year={2011}\n}\n"

a		:	List[Any]      					=			"\\nMean Absolute Error (MAE) is the mean of the magnitude of difference between the predicted and actual\nvalues.\n"


a		:	Dict      					=			"\nArgs:\n    predictions: array-like of shape (n_samples,) or (n_samples, n_outputs)\n        Estimated target values.\n    references: array-like of shape (n_samples,) or (n_samples, n_outputs)\n        Ground truth (correct) target values.\n    sample_weight: array-like of shape (n_samples,), default=None\n        Sample weights.\n    multioutput: {\"raw_values\", \"uniform_average\"} or array-like of shape (n_outputs,), default=\"uniform_average\"\n        Defines aggregating of multiple output values. Array-like value defines weights used to average errors.\n\n                 \"raw_values\" : Returns a full set of errors in case of multioutput input.\n\n                 \"uniform_average\" : Errors of all outputs are averaged with uniform weight.\n\nReturns:\n    mae : mean absolute error.\n        If multioutput is \"raw_values\", then mean absolute error is returned for each output separately. If multioutput is \"uniform_average\" or an ndarray of weights, then the weighted average of all output errors is returned.\n        MAE output is non-negative floating point. The best value is 0.0.\nExamples:\n\n    >>> mae_metric = datasets.load_metric(\"mae\")\n    >>> predictions = [2.5, 0.0, 2, 8]\n    >>> references = [3, -0.5, 2, 7]\n    >>> results = mae_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {'mae': 0.5}\n\n    If you're using multi-dimensional lists, then set the config as follows :\n\n    >>> mae_metric = datasets.load_metric(\"mae\", \"multilist\")\n    >>> predictions = [[0.5, 1], [-1, 1], [7, -6]]\n    >>> references = [[0, 2], [-1, 2], [8, -5]]\n    >>> results = mae_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {'mae': 0.75}\n    >>> results = mae_metric.compute(predictions=predictions, references=references, multioutput='raw_values')\n    >>> print(results)\n    {'mae': array([0.5, 1. ])}\n"
@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION							,	_KWARGS_DESCRIPTION       )
class    a   (			datasets.Metric       ):



      """simple docstring"""


      def      UpperCAmelCase				(				self :      str )							->				Optional[Any]:
       return datasets.MetricInfo(
           description=_DESCRIPTION		,				citation=_CITATION		,				inputs_description=_KWARGS_DESCRIPTION		,				features=datasets.Features(self._get_feature_types() )		,				reference_urls=[
               """https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_absolute_error.html"""
           ]		,				)
      def      UpperCAmelCase				(				self :      List[str] )							->				int:






       if self.config_name == "multilist":
        return {
            "predictions": datasets.Sequence(datasets.Value("""float""" ) ),
            "references": datasets.Sequence(datasets.Value("""float""" ) ),
        }
       else:
        return {
            "predictions": datasets.Value("""float""" ),
            "references": datasets.Value("""float""" ),
        }




      def      UpperCAmelCase				(				self :      List[Any]		,				__lowercase :      int		,				__lowercase :      List[Any]		,				__lowercase :      List[Any]=None		,				__lowercase :      str="uniform_average" )							->				Any:
       __UpperCAmelCase							:     Any									=  mean_absolute_error(SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				sample_weight=SCREAMING_SNAKE_CASE_		,				multioutput=SCREAMING_SNAKE_CASE_ )

       return {"mae": mae_score}










import copy

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


a		:	Optional[Any]      					=			logging.get_logger(__name__)

a		:	int      					=			{
    "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   (			lowercase__       ):



      """simple docstring"""


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


class    a   (			lowercase__       ):



      """simple docstring"""


      a  :			Tuple								=     'musicgen'
      a  :			int								=     True
      def __init__(				self :      Any		,				**__lowercase :      Tuple )							->				Union[str, Any]:
        super().__init__(**__lowercase )
        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""" )

        __UpperCAmelCase							:     int									=  kwargs.pop("""text_encoder""" )
        __UpperCAmelCase							:     str									=  text_encoder_config.pop("""model_type""" )

        __UpperCAmelCase							:     Tuple									=  kwargs.pop("""audio_encoder""" )
        __UpperCAmelCase							:     Optional[Any]									=  audio_encoder_config.pop("""model_type""" )

        __UpperCAmelCase							:     Optional[Any]									=  kwargs.pop("""decoder""" )

        __UpperCAmelCase							:     Any									=  AutoConfig.for_model(__lowercase		,				**__lowercase )
        __UpperCAmelCase							:     Dict									=  AutoConfig.for_model(__lowercase		,				**__lowercase )
        __UpperCAmelCase							:     Any									=  MusicgenDecoderConfig(**__lowercase )
        __UpperCAmelCase							:     int									=  True
      @classmethod
      def      UpperCAmelCase				(				cls :      Optional[Any]		,				__lowercase :      PretrainedConfig		,				__lowercase :      PretrainedConfig		,				__lowercase :      MusicgenDecoderConfig		,				**__lowercase :      List[Any]		,				)							->				List[str]:
        return cls(
            text_encoder=text_encoder_config.to_dict()		,				audio_encoder=audio_encoder_config.to_dict()		,				decoder=decoder_config.to_dict()		,				**__lowercase		,				)




      def      UpperCAmelCase				(				self :      Any )							->				int:
        __UpperCAmelCase							:     Optional[Any]									=  copy.deepcopy(self.__dict__ )
        __UpperCAmelCase							:     List[Any]									=  self.text_encoder.to_dict()
        __UpperCAmelCase							:     str									=  self.audio_encoder.to_dict()
        __UpperCAmelCase							:     List[str]									=  self.decoder.to_dict()
        __UpperCAmelCase							:     List[str]									=  self.__class__.model_type
        return output


