
'''simple docstring'''
import unittest
from functools import partial

import torch

from accelerate import Accelerator, debug_launcher
from accelerate.state import AcceleratorState, GradientState
from accelerate.test_utils import require_cpu, require_huggingface_suite
from accelerate.utils import GradientAccumulationPlugin




def 					_UpperCamelCase		(    SCREAMING_SNAKE_CASE__=2      ,    SCREAMING_SNAKE_CASE__=True      ,    SCREAMING_SNAKE_CASE__=False       )   ->				Dict:


		'''simple docstring'''


		snake_case   :    Tuple			       =		Accelerator(step_scheduler_with_optimizer=SCREAMING_SNAKE_CASE__      ,    split_batches=SCREAMING_SNAKE_CASE__       )
		snake_case   :    int			       =		torch.nn.Linear(2      ,    4       )
		snake_case   :    Optional[Any]			       =		torch.optim.AdamW(model.parameters()      ,    lr=1.0       )
		snake_case   :    Dict			       =		torch.optim.lr_scheduler.OneCycleLR(SCREAMING_SNAKE_CASE__      ,    max_lr=0.01      ,    steps_per_epoch=2      ,    epochs=1       )
		snake_case       ,snake_case       ,snake_case   :    Dict			       =		accelerator.prepare(SCREAMING_SNAKE_CASE__      ,    SCREAMING_SNAKE_CASE__      ,    SCREAMING_SNAKE_CASE__       )

		# Optimizer has stepped
		scheduler.step()
		if step_scheduler_with_optimizer or (num_processes == 1):
				assert (
				    scheduler.scheduler.last_epoch == num_processes
				), F'Last Epoch ({scheduler.scheduler.last_epoch}) != Num Processes ({num_processes})'
		else:
				assert (
				    scheduler.scheduler.last_epoch != num_processes
				), F'Last Epoch ({scheduler.scheduler.last_epoch}) == Num Processes ({num_processes})'




def 					_UpperCamelCase		(    SCREAMING_SNAKE_CASE__=2      ,    SCREAMING_SNAKE_CASE__=True      ,    SCREAMING_SNAKE_CASE__=False       )   ->				Tuple:


		'''simple docstring'''


		snake_case   :    List[str]			       =		Accelerator(step_scheduler_with_optimizer=SCREAMING_SNAKE_CASE__      ,    split_batches=SCREAMING_SNAKE_CASE__       )
		snake_case   :    List[Any]			       =		torch.nn.Linear(2      ,    4       )
		snake_case   :    Optional[Any]			       =		torch.optim.AdamW(model.parameters()      ,    lr=1.0       )
		snake_case   :    str			       =		torch.optim.lr_scheduler.LambdaLR(SCREAMING_SNAKE_CASE__      ,    lr_lambda=lambda SCREAMING_SNAKE_CASE__       : 1 - n / 10       )
		snake_case       ,snake_case       ,snake_case   :    Optional[int]			       =		accelerator.prepare(SCREAMING_SNAKE_CASE__      ,    SCREAMING_SNAKE_CASE__      ,    SCREAMING_SNAKE_CASE__       )

		# Optimizer has stepped
		snake_case   :    Optional[Any]			       =		False
		scheduler.step()
		snake_case   :    List[Any]			       =		1 - (num_processes if (step_scheduler_with_optimizer and not split_batches) else 1) / 10
		assert (
		    scheduler.get_last_lr()[0] == expected_lr
		), F'Wrong lr found at first step, expected {expected_lr}, got {scheduler.get_last_lr()[0]}'

		# Optimizer has not stepped
		snake_case   :    Optional[Any]			       =		True
		scheduler.step()
		if not step_scheduler_with_optimizer:
				snake_case   :    Tuple			       =		1 - 2 / 10
		assert (
		    scheduler.get_last_lr()[0] == expected_lr
		), F'Wrong lr found at second step, expected {expected_lr}, got {scheduler.get_last_lr()[0]}'




def 					_UpperCamelCase		(    SCREAMING_SNAKE_CASE__ = 2       )   ->				int:


		'''simple docstring'''


		from transformers import get_linear_schedule_with_warmup

		snake_case   :    Optional[Any]			       =		[1, 2, 4]
		for num_steps in steps:
				snake_case   :    Any			       =		GradientAccumulationPlugin(num_steps=SCREAMING_SNAKE_CASE__      ,    adjust_scheduler=num_steps > 1       )
				snake_case   :    int			       =		Accelerator(gradient_accumulation_plugin=SCREAMING_SNAKE_CASE__       )
				snake_case   :    int			       =		torch.nn.Linear(2      ,    4       )
				snake_case   :    List[str]			       =		torch.optim.AdamW(model.parameters()      ,    lr=10.0       )
				snake_case   :    str			       =		get_linear_schedule_with_warmup(optimizer=SCREAMING_SNAKE_CASE__      ,    num_warmup_steps=0      ,    num_training_steps=20       )

				snake_case       ,snake_case       ,snake_case   :    Any			       =		accelerator.prepare(SCREAMING_SNAKE_CASE__      ,    SCREAMING_SNAKE_CASE__      ,    SCREAMING_SNAKE_CASE__       )

				for i in range(10 * num_steps       ):
						with accelerator.accumulate(SCREAMING_SNAKE_CASE__       ):
								optimizer.step()
								scheduler.step()

						if i == (10 * num_steps - 2):
								assert (
								    scheduler.get_last_lr()[0] != 0
								), F'Wrong lr found at second-to-last step, expected non-zero, got {scheduler.get_last_lr()[0]}. num_steps: {num_steps}'
				assert (
				    scheduler.get_last_lr()[0] == 0
				), F'Wrong lr found at last step, expected 0, got {scheduler.get_last_lr()[0]}'
				GradientState._reset_state()






@require_cpu
class      snake_case__    (	unittest.TestCase ):







		"""simple docstring"""

		def 	lowerCAmelCase							(	self							:       Tuple	)		->       List[Any]:






				"""simple docstring"""







				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1	)   ,     num_processes=1	)
				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1   ,     split_batches=UpperCamelCase__	)   ,     num_processes=1	)



		def 	lowerCAmelCase							(	self							:       Optional[Any]	)		->       Union[str, Any]:






				"""simple docstring"""







				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1	)   ,     num_processes=1	)
				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1   ,     split_batches=UpperCamelCase__	)   ,     num_processes=1	)



		def 	lowerCAmelCase							(	self							:       List[str]	)		->       str:






				"""simple docstring"""







				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1   ,     step_scheduler_with_optimizer=UpperCamelCase__	)   ,     num_processes=1	)



		def 	lowerCAmelCase							(	self							:       Optional[int]	)		->       Any:






				"""simple docstring"""







				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1   ,     step_scheduler_with_optimizer=UpperCamelCase__	)   ,     num_processes=1	)



		def 	lowerCAmelCase							(	self							:       Tuple	)		->       Tuple:






				"""simple docstring"""







				AcceleratorState._reset_state(UpperCamelCase__	)
				debug_launcher(UpperCamelCase__	)
				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1   ,     split_batches=UpperCamelCase__	)   ,     num_processes=1	)



		def 	lowerCAmelCase							(	self							:       Optional[Any]	)		->       Optional[int]:






				"""simple docstring"""







				AcceleratorState._reset_state(UpperCamelCase__	)
				debug_launcher(UpperCamelCase__	)
				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1   ,     split_batches=UpperCamelCase__	)   ,     num_processes=1	)



		def 	lowerCAmelCase							(	self							:       List[Any]	)		->       Dict:






				"""simple docstring"""







				AcceleratorState._reset_state(UpperCamelCase__	)
				debug_launcher(partial(UpperCamelCase__   ,     step_scheduler_with_optimizer=UpperCamelCase__	)	)



		def 	lowerCAmelCase							(	self							:       Tuple	)		->       str:






				"""simple docstring"""







				AcceleratorState._reset_state(UpperCamelCase__	)
				debug_launcher(partial(UpperCamelCase__   ,     step_scheduler_with_optimizer=UpperCamelCase__	)	)



		@require_huggingface_suite
		def 	lowerCAmelCase							(	self							:       str	)		->       Tuple:






				"""simple docstring"""







				AcceleratorState._reset_state(UpperCamelCase__	)
				debug_launcher(partial(UpperCamelCase__   ,     num_processes=1	)	)
				debug_launcher(UpperCamelCase__	)







"""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)



