



"""simple docstring"""







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


UpperCAmelCase:   Any       			=							random.Random()


def       __SCREAMING_SNAKE_CASE      (   __UpperCAmelCase					,							__UpperCAmelCase=1.0					,							__UpperCAmelCase=None					,							__UpperCAmelCase=None	):
		if rng is None:
				_lowercase							:      Union[str, Any]			=					global_rng

		_lowercase							:      int			=					[]
		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    UpperCamelCase     (			unittest.TestCase    ):




	"""simple docstring"""






	def 					lowerCamelCase__ (			self					):
			_lowercase							:      Optional[Any]			=					"""facebook/musicgen-small"""
			_lowercase							:      Tuple			=					tempfile.mkdtemp()






	def 					lowerCamelCase__ (			self							,**UpperCAmelCase_					):
			return TaTokenizer.from_pretrained(self.checkpoint							,**UpperCAmelCase_					)






	def 					lowerCamelCase__ (			self							,**UpperCAmelCase_					):
			return EncodecFeatureExtractor.from_pretrained(self.checkpoint							,**UpperCAmelCase_					)






	def 					lowerCamelCase__ (			self					):
			shutil.rmtree(self.tmpdirname					)






	def 					lowerCamelCase__ (			self					):
			_lowercase							:      Union[str, Any]			=					self.get_tokenizer()
			_lowercase							:      Dict			=					self.get_feature_extractor()

			_lowercase							:      Tuple			=					MusicgenProcessor(tokenizer=UpperCAmelCase_							,feature_extractor=UpperCAmelCase_					)

			processor.save_pretrained(self.tmpdirname					)
			_lowercase							:      Optional[int]			=					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 					lowerCamelCase__ (			self					):
			_lowercase							:      int			=					MusicgenProcessor(tokenizer=self.get_tokenizer()							,feature_extractor=self.get_feature_extractor()					)
			processor.save_pretrained(self.tmpdirname					)

			_lowercase							:      List[str]			=					self.get_tokenizer(bos_token="""(BOS)"""							,eos_token="""(EOS)"""					)
			_lowercase							:      Tuple			=					self.get_feature_extractor(do_normalize=UpperCAmelCase_							,padding_value=1.0					)

			_lowercase							:      Optional[Any]			=					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 					lowerCamelCase__ (			self					):
			_lowercase							:      Union[str, Any]			=					self.get_feature_extractor()
			_lowercase							:      Any			=					self.get_tokenizer()

			_lowercase							:      Union[str, Any]			=					MusicgenProcessor(tokenizer=UpperCAmelCase_							,feature_extractor=UpperCAmelCase_					)

			_lowercase							:      Union[str, Any]			=					floats_list((3, 10_00)					)

			_lowercase							:      Tuple			=					feature_extractor(UpperCAmelCase_							,return_tensors="""np"""					)
			_lowercase							:      Any			=					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 					lowerCamelCase__ (			self					):
			_lowercase							:      int			=					self.get_feature_extractor()
			_lowercase							:      Tuple			=					self.get_tokenizer()

			_lowercase							:      List[str]			=					MusicgenProcessor(tokenizer=UpperCAmelCase_							,feature_extractor=UpperCAmelCase_					)

			_lowercase							:      Tuple			=					"""This is a test string"""

			_lowercase							:      List[str]			=					processor(text=UpperCAmelCase_					)

			_lowercase							:      int			=					tokenizer(UpperCAmelCase_					)

			for key in encoded_tok.keys():
					self.assertListEqual(encoded_tok[key]							,encoded_processor[key]					)






	def 					lowerCamelCase__ (			self					):
			_lowercase							:      Any			=					self.get_feature_extractor()
			_lowercase							:      Optional[Any]			=					self.get_tokenizer()

			_lowercase							:      Optional[int]			=					MusicgenProcessor(tokenizer=UpperCAmelCase_							,feature_extractor=UpperCAmelCase_					)

			_lowercase							:      int			=					[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

			_lowercase							:      Any			=					processor.batch_decode(sequences=UpperCAmelCase_					)
			_lowercase							:      List[str]			=					tokenizer.batch_decode(UpperCAmelCase_					)

			self.assertListEqual(UpperCAmelCase_							,UpperCAmelCase_					)






	def 					lowerCamelCase__ (			self					):
			_lowercase							:      Optional[Any]			=					self.get_feature_extractor()
			_lowercase							:      Optional[int]			=					self.get_tokenizer()

			_lowercase							:      List[Any]			=					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 					lowerCamelCase__ (			self					):
			_lowercase							:      List[Any]			=					self.get_feature_extractor(padding_side="""left"""					)
			_lowercase							:      Tuple			=					self.get_tokenizer()

			_lowercase							:      Optional[Any]			=					MusicgenProcessor(tokenizer=UpperCAmelCase_							,feature_extractor=UpperCAmelCase_					)

			_lowercase							:      Any			=					[floats_list((1, x)					)[0] for x in range(5							,20							,5					)]
			_lowercase							:      List[str]			=					processor(UpperCAmelCase_					).padding_mask

			_lowercase							:      Union[str, Any]			=					np.asarray(floats_list((3, 20)					)					)[:, None, :]
			_lowercase							:      Optional[int]			=					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)					)








"""simple docstring"""







import requests
from bsa import BeautifulSoup


def       __SCREAMING_SNAKE_CASE      (   __UpperCAmelCase					,							__UpperCAmelCase	):
		_lowercase							:      Dict			=					(
		    """https://www.horoscope.com/us/horoscopes/general/"""
		    F"""horoscope-general-daily-{day}.aspx?sign={zodiac_sign}"""
		)
		_lowercase							:      Any			=					BeautifulSoup(requests.get(__UpperCAmelCase	).content					,							"""html.parser"""	)
		return soup.find("""div"""					,							class_="""main-horoscope"""	).p.text


if __name__ == "__main__":
		print("""Daily Horoscope. \n""")
		print(
		    """enter your Zodiac sign number:\n""",
		    """1. Aries\n""",
		    """2. Taurus\n""",
		    """3. Gemini\n""",
		    """4. Cancer\n""",
		    """5. Leo\n""",
		    """6. Virgo\n""",
		    """7. Libra\n""",
		    """8. Scorpio\n""",
		    """9. Sagittarius\n""",
		    """10. Capricorn\n""",
		    """11. Aquarius\n""",
		    """12. Pisces\n""",
		)
		UpperCAmelCase:   Union[str, Any]       			=							int(input("""number> """).strip())
		print("""choose some day:\n""", """yesterday\n""", """today\n""", """tomorrow\n""")
		UpperCAmelCase:   List[Any]       			=							input("""enter the day> """)
		UpperCAmelCase:   List[Any]       			=							horoscope(zodiac_sign, day)
		print(horoscope_text)



