code: 
  
  import random
  import shutil
  import tempfile
  import unittest
  
  import numpy as np
  
  from transformers import TaTokenizer, TaTokenizerFast
  from transformers.testing_utils import require_sentencepiece, require_torch
  from transformers.utils.import_utils import is_speech_available, is_torch_available
  
  
  if is_torch_available():
  				pass
  
  if is_speech_available():
  				from transformers import EncodecFeatureExtractor, MusicgenProcessor
  
  
  A_:      int        =			random.Random()
  
  
  def 					__lowerCAmelCase			(  _A ,_A=1.0 ,_A=None ,_A=None					):
  
  
  
  							"""simple docstring"""
  
  
  							if rng is None:
  														_lowercase				=	global_rng
  
  							_lowercase				=	[]
  							for batch_idx in range(shape[0]					):
  														values.append([]					)
  														for _ in range(shape[1]					):
  																					values[-1].append(rng.random() * scale					)
  
  							return values
  
  
  
  
  
  
  
  @require_torch
  @require_sentencepiece
  class _lowercase					(       unittest.TestCase						):
  
  
  
  
  
  							"""simple docstring"""
  
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														_lowercase				=	"facebook/musicgen-small"
  														_lowercase				=	tempfile.mkdtemp()
  
  
  
  							def     _UpperCAmelCase       (    self     ,   **UpperCAmelCase  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														return TaTokenizer.from_pretrained(self.checkpoint     ,   **UpperCAmelCase  )
  
  
  
  							def     _UpperCAmelCase       (    self     ,   **UpperCAmelCase  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														return EncodecFeatureExtractor.from_pretrained(self.checkpoint     ,   **UpperCAmelCase  )
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														shutil.rmtree(self.tmpdirname  )
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														_lowercase				=	self.get_tokenizer()
  														_lowercase				=	self.get_feature_extractor()
  
  														_lowercase				=	MusicgenProcessor(tokenizer=UpperCAmelCase     ,   feature_extractor=UpperCAmelCase  )
  
  														processor.save_pretrained(self.tmpdirname  )
  														_lowercase				=	MusicgenProcessor.from_pretrained(self.tmpdirname  )
  
  														self.assertEqual(processor.tokenizer.get_vocab()     ,   tokenizer.get_vocab()  )
  														self.assertIsInstance(processor.tokenizer     ,   UpperCAmelCase  )
  
  														self.assertEqual(processor.feature_extractor.to_json_string()     ,   feature_extractor.to_json_string()  )
  														self.assertIsInstance(processor.feature_extractor     ,   UpperCAmelCase  )
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														_lowercase				=	MusicgenProcessor(tokenizer=self.get_tokenizer()     ,   feature_extractor=self.get_feature_extractor()  )
  														processor.save_pretrained(self.tmpdirname  )
  
  														_lowercase				=	self.get_tokenizer(bos_token="""(BOS)"""     ,   eos_token="""(EOS)"""  )
  														_lowercase				=	self.get_feature_extractor(do_normalize=UpperCAmelCase     ,   padding_value=1.0  )
  
  														_lowercase				=	MusicgenProcessor.from_pretrained(
  														    self.tmpdirname     ,   bos_token="""(BOS)"""     ,   eos_token="""(EOS)"""     ,   do_normalize=UpperCAmelCase     ,   padding_value=1.0  )
  
  														self.assertEqual(processor.tokenizer.get_vocab()     ,   tokenizer_add_kwargs.get_vocab()  )
  														self.assertIsInstance(processor.tokenizer     ,   UpperCAmelCase  )
  
  														self.assertEqual(processor.feature_extractor.to_json_string()     ,   feature_extractor_add_kwargs.to_json_string()  )
  														self.assertIsInstance(processor.feature_extractor     ,   UpperCAmelCase  )
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														_lowercase				=	self.get_feature_extractor()
  														_lowercase				=	self.get_tokenizer()
  
  														_lowercase				=	MusicgenProcessor(tokenizer=UpperCAmelCase     ,   feature_extractor=UpperCAmelCase  )
  
  														_lowercase				=	floats_list((3, 1000)  )
  
  														_lowercase				=	feature_extractor(UpperCAmelCase     ,   return_tensors="""np"""  )
  														_lowercase				=	processor(UpperCAmelCase     ,   return_tensors="""np"""  )
  
  														for key in input_feat_extract.keys():
  																					self.assertAlmostEqual(input_feat_extract[key].sum()     ,   input_processor[key].sum()     ,   delta=1e-2  )
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														_lowercase				=	self.get_feature_extractor()
  														_lowercase				=	self.get_tokenizer()
  
  														_lowercase				=	MusicgenProcessor(tokenizer=UpperCAmelCase     ,   feature_extractor=UpperCAmelCase  )
  
  														_lowercase				=	"This is a test string"
  
  														_lowercase				=	processor(text=UpperCAmelCase  )
  
  														_lowercase				=	tokenizer(UpperCAmelCase  )
  
  														for key in encoded_tok.keys():
  																					self.assertListEqual(encoded_tok[key]     ,   encoded_processor[key]  )
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														_lowercase				=	self.get_feature_extractor()
  														_lowercase				=	self.get_tokenizer()
  
  														_lowercase				=	MusicgenProcessor(tokenizer=UpperCAmelCase     ,   feature_extractor=UpperCAmelCase  )
  
  														_lowercase				=	[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]
  
  														_lowercase				=	processor.batch_decode(sequences=UpperCAmelCase  )
  														_lowercase				=	tokenizer.batch_decode(UpperCAmelCase  )
  
  														self.assertListEqual(UpperCAmelCase     ,   UpperCAmelCase  )
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														_lowercase				=	self.get_feature_extractor()
  														_lowercase				=	self.get_tokenizer()
  
  														_lowercase				=	MusicgenProcessor(tokenizer=UpperCAmelCase     ,   feature_extractor=UpperCAmelCase  )
  
  														self.assertListEqual(
  														    processor.model_input_names     ,   feature_extractor.model_input_names     ,   msg="""`processor` and `feature_extractor` model input names do not match"""     ,   )
  
  
  
  							def     _UpperCAmelCase       (    self  ):
  
  
  
  
  
  
  
  														'''simple docstring'''
  
  
  
  
  
  
  														_lowercase				=	self.get_feature_extractor(padding_side="""left"""  )
  														_lowercase				=	self.get_tokenizer()
  
  														_lowercase				=	MusicgenProcessor(tokenizer=UpperCAmelCase     ,   feature_extractor=UpperCAmelCase  )
  
  														_lowercase				=	[floats_list((1, x)  )[0] for x in range(5     ,   20     ,   5  )]
  														_lowercase				=	processor(UpperCAmelCase  ).padding_mask
  
  														_lowercase				=	np.asarray(floats_list((3, 20)  )  )[:, None, :]
  														_lowercase				=	processor.batch_decode(UpperCAmelCase     ,   padding_mask=UpperCAmelCase  )
  
  														self.assertIsInstance(UpperCAmelCase     ,   UpperCAmelCase  )
  
  														for audio in decoded_audios:
  																					self.assertIsInstance(UpperCAmelCase     ,   np.ndarray  )
  
  														self.assertTrue(decoded_audios[0].shape == (1, 10)  )
  														self.assertTrue(decoded_audios[1].shape == (1, 15)  )
  														self.assertTrue(decoded_audios[2].shape == (1, 20)  )
  
  
  
style_context: def 					__lowerCAmelCase			(  _A					):
  
  
  
  							"""simple docstring"""
  
  
  							if len(_A					) <= 1:
  														return data
  							else:
  														return [
  														    *quick_sort([e for e in data[1:] if e <= data[0]]					),
  														    data[0],
  														    *quick_sort([e for e in data[1:] if e > data[0]]					),
  														]
  
  
  if __name__ == "__main__":
  				import doctest
  
  				doctest.testmod()
  
  
  